DynamicMethodTrait

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

Properties

public static property atk4\core\DynamicMethodTrait::$_dynamicMethodTrait
Check this property to see if trait is present in the object.
Source:vendor/atk4/core/src/DynamicMethodTrait.php#16
Type:bool

Methods

public atk4\core\DynamicMethodTrait::__call($method, $arguments)
Magic method - tries to call dynamic method and throws exception if
this was not possible.
Source:

vendor/atk4/core/src/DynamicMethodTrait.php#25

Parameters:
  • $arguments (array) Array of arguments to pass to this method
public atk4\core\DynamicMethodTrait::tryCall($method, $arguments)
Tries to call dynamic method.
Source:

vendor/atk4/core/src/DynamicMethodTrait.php#47

Parameters:
  • $arguments (array) Array of arguments to pass to this method
Returns:

mixed | null

public atk4\core\DynamicMethodTrait::addMethod($name, $callable)
Add new method for this object.
Source:

vendor/atk4/core/src/DynamicMethodTrait.php#69

Parameters:
  • $name (string | array) Name of new method of $this object
  • $callable (callable) Callback
Returns:

$this

public atk4\core\DynamicMethodTrait::hasMethod($name)
Return if this object has specified method (either native or dynamic).
Source:

vendor/atk4/core/src/DynamicMethodTrait.php#108

Parameters:
  • $name (string) Name of the method
Returns:

bool

public atk4\core\DynamicMethodTrait::removeMethod($name)
Remove dynamically registered method.
Source:

vendor/atk4/core/src/DynamicMethodTrait.php#122

Parameters:
  • $name (string) Name of the method
Returns:

$this

public atk4\core\DynamicMethodTrait::addGlobalMethod($name, $callable)
Agile Toolkit objects allow method injection. This is quite similar
to technique used in JavaScript:.
obj.test = function() { .. }

All non-existent method calls on all Agile Toolkit objects will be
tried against local table of registered methods and then against
global registered methods.

addGlobalMethod allows you to register a globally-recognized method for
all Agile Toolkit objects. PHP is not particularly fast about executing
methods like that, but this technique can be used for adding
backward-compatibility or debugging, etc.
Source:

vendor/atk4/core/src/DynamicMethodTrait.php#152

Parameters:
  • $name (string) Name of the method
  • $callable (callable) Calls your function($object, $arg1, $arg2)
See:

\atk4\core\self::hasMethod()

See:

\atk4\core\self::hasMethod()

public atk4\core\DynamicMethodTrait::hasGlobalMethod($name)
Return true if such global method exists.
Source:

vendor/atk4/core/src/DynamicMethodTrait.php#172

Parameters:
  • $name (string) Name of the method
Returns:

bool

public atk4\core\DynamicMethodTrait::removeGlobalMethod($name)
Remove dynamically registered global method.
Source:

vendor/atk4/core/src/DynamicMethodTrait.php#187

Parameters:
  • $name (string) Name of the method
Returns:

$this