Tribe__Utils__Callback::get( string $slug, string $method )
Returns a callable for on this class that doesn’t exist, but passes in the Key for Di52 Slug and it’s method and arguments. It will relayed via overloading __call() on this same class.
Contents
The lambda function suitable to use as a callback; when called the function will build the implementation bound to $classOrInterface and return the value of a call to $method method with the call arguments.
Parameters
- $slug
-
(string) (Required) A class or interface fully qualified name or a string slug.
- $method
-
(string) (Required) The method that should be called on the resolved implementation with the specified array arguments.
Return
(array) The callable
Source
File: src/Tribe/Utils/Callback.php
public function get( $slug, $method ) {
$container = Tribe__Container::init();
$arguments = func_get_args();
$is_empty = 2 === count( $arguments );
// Remove Slug and Method
array_shift( $arguments );
array_shift( $arguments );
$item = (object) array(
'slug' => $slug,
'method' => $method,
'arguments' => $arguments,
'is_empty' => $is_empty,
);
$key = md5( json_encode( $item ) );
// Prevent this from been reset
if ( isset( $this->items[ $key ] ) ) {
return $this->items[ $key ];
}
$item->callback = $container->callback( $item->slug, $item->method );
$this->items[ $key ] = $item;
return array( $this, $this->prefix . $key );
}
Changelog
| Version | Description |
|---|---|
| 4.6.2 | Introduced. |