xplo.re Medusa Core Framework 3.2
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Event
  • Todo
  • Download

Namespaces

  • Core
    • Authentication
      • Auto
        • Driver
      • Driver
    • Cache
      • Driver
    • Charset
      • Driver
    • Configuration
      • Driver
    • Controller
    • Converter
      • Driver
    • Decoder
      • Driver
    • Encoder
      • Driver
    • Env
      • Authentication
      • Locale
      • Proxy
      • Server
        • HTTP
        • Redirect
        • X
    • Exception
    • Exchange
      • Driver
    • Fault
      • Formatter
        • Driver
      • Incident
        • Exception
      • Reporter
        • Driver
    • Field
    • Filter
      • Driver
    • Formatter
      • Driver
        • coreuimarkup
          • Token
    • Hash
    • Loader
    • Locale
    • Log
      • Driver
    • Module
      • Dependency
        • Requirement
          • Core
          • PHP
      • Linkage
        • Driver
    • PDF
    • Plugin
    • Query
      • Driver
    • Server
      • Driver
    • Session
      • Driver
    • Set
    • Storage
      • Driver
      • Field
        • Element
    • Stream
      • Driver
    • String
    • Translation
      • Driver
      • Language
        • Driver
    • Type
    • URI
      • Driver
    • Version
    • View
      • Driver
        • coreui
          • Control
            • Button
            • Table
          • Element
        • htmlbuilder
          • Tags
        • yui
          • Modules
  • None
  • PHP

Classes

  • Authentication
  • Authentication_Token
  • AutoLoader
  • Cache
  • Charset
  • ClassDescriptor
  • Closure
  • Configuration
  • Controller
  • Converter
  • Date
  • Decoder
  • Delegate
  • Dispatcher
  • Encoder
  • Env
  • Env_Field
  • Env_File
  • Env_FileList
  • Env_Request
  • Env_SERVER
  • Exchange
  • Fault
  • Field
  • Filter
  • Filter_Value
  • Formatter
  • Hash
  • IP
  • Loader
  • Locale
  • Locale_Node
  • Log
  • Module
  • Module_Iterator
  • Nothing
  • Object
  • OS
  • Plugin
  • Profiler
  • Query
  • Registry
  • Resource
  • Server
  • Session
  • Session_Token
  • Set
  • Storage
  • Storage_Result
  • Storage_Statement
  • Stream
  • Translation
  • URI
  • URI_Parameters
  • UUID
  • Value
  • Version
  • View

Interfaces

  • Accessor
  • Chainable
  • Comparable
  • Configurable
  • Equality
  • Identity
  • Inquiry
  • Masquerade
  • Mutator
  • SeekableStream
  • Storable
  • Variator

Exceptions

  • Exception

Constants

  • Copyright
  • ProductName
  • Version

Class Delegate

A delegate is a collection of callbacks that are invoked sequentially when the delegate itself is invoked.

Core\Object implements Core\Chainable
Extended by Core\Set implements Core\Accessor
Extended by Core\Delegate
Namespace: Core
Package: Core
Since: 3.0
Requires: PHP 5.3
Version: 1.1
Located at Delegate.inc.php

Methods summary

public mixed
# __invoke( )

Invokes all registered callbacks. Parameters are passed verbatim to the registered callbacks; all parameters are passed by value due to restrictions of the PHP engine. If parameters need to be modified by the invoked callback, use objects instead which are always passed by as references. Use Core\Delegate::invokeWithArguments() to pass arguments by reference.

Invokes all registered callbacks. Parameters are passed verbatim to the registered callbacks; all parameters are passed by value due to restrictions of the PHP engine. If parameters need to be modified by the invoked callback, use objects instead which are always passed by as references. Use Core\Delegate::invokeWithArguments() to pass arguments by reference.

Returns

mixed
Return value of last callback.

Remark

Callbacks are invoked in exactly the same order they have been registered.

Hence the PHP engine does not allow to dynamically retrieve a variable list of argument references, arguments can only be passed by value to the callback. Use objects if the callback is required to modify an argument.


See

Core\Delegate::invoke()
Core\Delegate::invokeWithArguments()

Since

3.0
public
# add( mixed $objectOrCallable, string $methodName = null )

Registers a new callback.

Registers a new callback.

Parameters

$objectOrCallable

Either a callable or an object or class name that combined with the method name argument forms a callable.

$methodName
Name of method if first argument is an object or class name.

Returns


$this

Throws

Core\Exception\Delegate
The provided callback is not callable.

Remark

Registering the same callback multiple times is possible. The callback will accordingly be invoked multiple times.


See

Core\Delegate::remove()

Since

3.0
public mixed
# invoke( )

Invokes all registered callbacks. Parameters are passed verbatim to the registered callbacks; all parameters are passed by value due to restrictions of the PHP engine. If parameters need to be modified by the invoked callback, use objects instead which are always passed by as references. Use Core\Delegate::invokeWithArguments() to pass arguments by reference.

Invokes all registered callbacks. Parameters are passed verbatim to the registered callbacks; all parameters are passed by value due to restrictions of the PHP engine. If parameters need to be modified by the invoked callback, use objects instead which are always passed by as references. Use Core\Delegate::invokeWithArguments() to pass arguments by reference.

Returns

mixed
Return value of last callback.

Remark

Callbacks are invoked in exactly the same order they have been registered.

Hence the PHP engine does not allow to dynamically retrieve a variable list of argument references, arguments can only be passed by value to the callback. Use objects if the callback is required to modify an argument.


See

Core\Delegate::__invoke()
Core\Delegate::invokeWithArguments()

Since

3.0
public mixed
# invokeWithArguments( array $arguments = null, callable $invocationCallback = null )

Invokes all registered callbacks. Parameters are passed as an array, which allows the delegate to pass arguments as references to the registered callbacks. Use an ampersand ("&") prefix for variables in the supplied array to declare those as references:

Invokes all registered callbacks. Parameters are passed as an array, which allows the delegate to pass arguments as references to the registered callbacks. Use an ampersand ("&") prefix for variables in the supplied array to declare those as references:

$delegate->invokeWithArguments (array ($a, &$b, $object));

In the example code, scalar a is passed by value whereas scalar b is passed by reference. The object is always passed by reference.

Parameters

$arguments
Optional array of arguments to pass to callbacks.
$invocationCallback

Optional callback method called after each callback invoked to evaluate the return value of the callback. If this value is null, all callbacks are invoked regardless of their return value and the last return value is returned, as in Core\Delegate::invoke().

The callback must accept exactly two argument: An index and the return value of the invoked callback. The index is the iteration invariant over the number of callbacks registered with the delegate. If the callback returns false, the execution of callbacks is stopped and the last return value is returned. The callback may also modify the return value by accepting the argument as a reference and then modify its value; the modified value will be returned instead.

Returns

mixed
Return value of last callback.

Remark

Callbacks are invoked in exactly the same order they have been registered.


See

Core\Delegate::invoke()

Since

3.1
public boolean
# remove( mixed $objectOrCallable, string $methodName = null )

Removes a callback from the delegate.

Removes a callback from the delegate.

Parameters

$objectOrCallable

Either a callable or an object or class name that combined with the method name argument forms a callable.

$methodName
Name of method if first argument is an object or class name.

Returns

boolean
true on successful removal or false, if the callback was not found.

Remark

Multiple registrations of the same callback require multiple releases of the callback. Each call removes the first matching callback list entry.


See

Core\Delegate::add()

Since

3.1

Methods inherited from Core\Set

__get(), __isset()

Methods inherited from Core\Object

__autocreateFactory(), __call(), __processParameters(), __toString(), attachMethod(), chain(), getValueForKey(), getValueForKeyPath(), getValueForUndefinedKey(), hash(), issetValueForKey(), setValueForKey(), setValueForKeyPath(), setValueForUndefinedKey(), uuid()

Constants summary

Constants inherited from Core\Object

AnyParameterType, AutochainParameterType, AutocreateParameterType, BooleanParameterType, CharParameterType, EnumParameterType, IntegerParameterType, RealParameterType, StringParameterType, UserParameterType

Properties summary

protected callable[] $_v_callbacks

Array of registered callbacks.

Array of registered callbacks.

Since

3.0
# array ()

Magic properties inherited from Core\Object

$hash, $uuid

xplo.re Medusa Core Framework 3.2 API documentation generated by ApiGen