ContainerTrait

trait atk4\core\ContainerTrait
This trait makes it possible for you to add child objects
into your object.
Source:vendor/atk4/core/src/ContainerTrait.php#9

Properties

public static property atk4\core\ContainerTrait::$_containerTrait
Check this property to see if trait is present in the object.
Source:vendor/atk4/core/src/ContainerTrait.php#16
Type:bool
public static property atk4\core\ContainerTrait::$elements
short_name => object hash of children objects. If the child is not
trackable, then object will be set to “true” (to avoid extra reference).
Source:vendor/atk4/core/src/ContainerTrait.php#24
Type:array

Methods

public atk4\core\ContainerTrait::_unique_element($desired)
Returns unique element name based on desired name.
Source:

vendor/atk4/core/src/ContainerTrait.php#35

Parameters:
  • $desired (string)
Returns:

string

public atk4\core\ContainerTrait::add($obj, $args=[])
If you are using ContainerTrait only, then you can safely
use this add() method. If you are also using factory, or
initializer then redefine add() and call
_add_Container, _add_Factory,.
Source:

vendor/atk4/core/src/ContainerTrait.php#60

Parameters:
  • $obj (mixed)
  • $args (array | string)
Throws:

\atk4\core\Exception

Returns:

object

protected atk4\core\ContainerTrait::_add_Container($element, $args=[])
Extension to add() method which will perform linking of
the object with the current class.
Source:

vendor/atk4/core/src/ContainerTrait.php#101

Parameters:
  • $element (object)
  • $args (array | string)
Throws:

\atk4\core\Exception

Returns:

object

public atk4\core\ContainerTrait::removeElement($short_name)
Remove child element if it exists.
Source:

vendor/atk4/core/src/ContainerTrait.php#181

Parameters:
  • $short_name (string) short name of the element
Throws:

\atk4\core\Exception

Returns:

$this

protected atk4\core\ContainerTrait::_shorten($desired)
Method used internally for shortening object names.
Source:

vendor/atk4/core/src/ContainerTrait.php#207

Parameters:
  • $desired (string) Desired name of new object.
Returns:

string Shortened name of new object.

public atk4\core\ContainerTrait::getElement($short_name)
Find child element by its short name. Use in chaining.
Exception if not found.
Source:

vendor/atk4/core/src/ContainerTrait.php#246

Parameters:
  • $short_name (string) Short name of the child element
Throws:

\atk4\core\Exception

Returns:

object

public atk4\core\ContainerTrait::hasElement($short_name)
Find child element. Use in condition.
Source:

vendor/atk4/core/src/ContainerTrait.php#266

Parameters:
  • $short_name (string) Short name of the child element
Returns:

object | bool