$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 [ $this, $this->prefix . $key ]; } /** * Returns the Value passed as a simple Routing method for tribe_callback_return * * @since 4.6.2 * * @param mixed $value Value to be Routed * * @return mixed */ public function return_value( $value ) { return $value; } /** * Calls the Lambda function provided by Di52 to allow passing of Params without having to create more * methods into classes for simple callbacks that will only have a pre-determined value. * * @since 4.6.2 * * @param string $slug A class or interface fully qualified name or a string slug. * @param string $method The method that should be called on the resolved implementation with the * specified array arguments. * * @return mixed The Return value used */ public function __call( $method, $args ) { $key = str_replace( $this->prefix, '', $method ); if ( ! isset( $this->items[ $key ] ) ) { return false; } $item = $this->items[ $key ]; // Allow for previous compatibility with tribe_callback if ( ! $item->is_empty ) { $args = $item->arguments; } return call_user_func_array( $item->callback, $args ); } /** * Tribe__Utils__Callback constructor. * * This is used to wrap a Tribe callable couple, a bound slug and method, to be used as a serializable callback. * * @since 4.9.5 * * @param string $slug The slug or class to call. * @param string $method The method to call on the slug or class. */ public function __construct( $slug = null, $method = null ) { $this->slug = $slug; $this->method = $method; } /** * Returns the list of properties that should be serialized for the object. * * @since 4.9.5 * * @return array An array of properties that should be serialized. */ public function __sleep() { return [ 'slug', 'method' ]; } /** * Returns this callback slug or class. * * This only makes sense if this class is being used to wrap a Tribe callback couple (slug and method). * * @since 4.9.5 * * @return string|null This Tribe callback wrapper slug or class. */ public function get_slug() { return $this->slug; } /** * Returns this callback method. * * This only makes sense if this class is being used to wrap a Tribe callback couple (slug and method). * * @since 4.9.5 * * @return string|null This Tribe callback method. */ public function get_method() { return $this->method; } }