PRADO Component Framework for PHP 5
  • Home
  • About
  • Testimonials
  • Demos
  • Download
  • Documentation
  • Forum
  • Development
  • Tutorials
  • Class Docs
  • API Manual
  • Wiki

Packages

  • None
  • System
    • Caching
    • Collections
    • Data
      • ActiveRecord
        • Relations
        • Scaffold
          • InputBuilder
      • Commom
        • Sqlite
      • Common
        • Mssql
        • Mysql
        • Oracle
        • Pgsql
        • Sqlite
      • DataGateway
      • SqlMap
        • Configuration
        • Statements
    • Exceptions
    • I18N
    • IO
    • Security
    • Util
    • Web
      • Javascripts
      • Services
      • UI
        • ActiveControls
        • WebControls
    • Xml
  • Wsat
    • pages
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Class TCallChain

TCallChain is a recursive event calling mechanism. This class implements the IDynamicMethods class so that any 'dy' event calls can be caught and patched through to the intended recipient

TComponent
Extended by TList implements IteratorAggregate, ArrayAccess, Countable
Extended by TCallChain implements IDynamicMethods
Package: System\Util
Copyright: Copyright © 2008-2014 Pradosoft
License: http://www.pradosoft.com/license/
Author: Brad Anderson <javalizard@gmail.com>
Since: 3.2.3
Located at Util/TCallChain.php
Methods summary
public
# __construct( string $method )

This initializes the list and the name of the method to be called

This initializes the list and the name of the method to be called

Parameters

$method
string
the name of the function call

Throws

TInvalidDataTypeException
If data is not null and neither an array nor an iterator.

Overrides

TList::__construct()
public
# addCall( string|array $method, array $args )

This initializes the list and the name of the method to be called

This initializes the list and the name of the method to be called

Parameters

$method
string|array
this is a callable function as a string or array with the object and method name as string
$args
array
The array of arguments to the function call chain
public
# call( )

This method calls the next Callable in the list. All of the method arguments coming into this method are substituted into the original method argument of call in the chain.

This method calls the next Callable in the list. All of the method arguments coming into this method are substituted into the original method argument of call in the chain.

If the original method call has these parameters

$originalobject->dyExampleMethod('param1', 'param2', 'param3')
$callchain->dyExampleMethod('alt1', 'alt2')

then the next call in the call chain will recieve the parameters as if this were called

$behavior->dyExampleMethod('alt1', 'alt2', 'param3', $callchainobject)

When dealing with IClassBehaviors, the first parameter of the stored argument list in 'dy' event calls is always the object containing the behavior. This modifies the parameter replacement mechanism slightly to leave the object containing the behavior alone and only replacing the other parameters in the argument list. As per TComponent::__call(), any calls to a 'dy' event do not need the object containing the behavior as the addition of the object to the argument list as the first element is automatic for IClassBehaviors.

The last parameter of the method parameter list for any callable in the call chain will be the TCallChain object itself. This is so that any behavior implementing these calls will have access to the call chain. Each callable should either call the TCallChain call method internally for direct chaining or call the method being chained (in which case the dynamic handler will pass through to this call method).

If the dynamic intra object/behavior event is not called in the behavior implemented dynamic method, it will return to this method and call the following behavior implementation so as no behavior with an implementation of the dynamic event is left uncalled. This does break the call chain though and will not act as a "parameter filter".

When there are no handlers or no handlers left, it returns the first parameter of the argument list.

public
# __dycall( string $method, array $args )

This catches all the unpatched dynamic events. When the method call matches the call chain method, it passes the arguments to the original __call (of the dynamic event being unspecified in TCallChain) and funnels into the method TCallChain::call(), so the next dynamic event handler can be called. If the original method call has these parameters

$originalobject->dyExampleMethod('param1', 'param2', 'param3')

and within the chained dynamic events, this can be called

class DyBehavior extends TBehavior {
public function dyExampleMethod($param1, $param2, $param3, $callchain)
$callchain->dyExampleMethod($param1, $param2, $param3)
}
{

to call the next event in the chain.

This catches all the unpatched dynamic events. When the method call matches the call chain method, it passes the arguments to the original __call (of the dynamic event being unspecified in TCallChain) and funnels into the method TCallChain::call(), so the next dynamic event handler can be called. If the original method call has these parameters

$originalobject->dyExampleMethod('param1', 'param2', 'param3')

and within the chained dynamic events, this can be called

class DyBehavior extends TBehavior {
public function dyExampleMethod($param1, $param2, $param3, $callchain)
$callchain->dyExampleMethod($param1, $param2, $param3)
}
{

to call the next event in the chain.

Parameters

$method
string
method name of the unspecified object method
$args
array
arguments to the unspecified object method

Implementation of

IDynamicMethods::__dycall()
Methods inherited from TList
add(), clear(), contains(), copyFrom(), count(), getCount(), getIterator(), getReadOnly(), indexOf(), insertAfter(), insertAt(), insertBefore(), itemAt(), mergeWith(), offsetExists(), offsetGet(), offsetSet(), offsetUnset(), remove(), removeAt(), setReadOnly(), toArray()
Methods inherited from TComponent
__call(), __destruct(), __get(), __isset(), __set(), __sleep(), __unset(), __wakeup(), addParsedObject(), asa(), attachBehavior(), attachBehaviors(), attachClassBehavior(), attachEventHandler(), canGetProperty(), canSetProperty(), clearBehaviors(), createdOnTemplate(), detachBehavior(), detachBehaviors(), detachClassBehavior(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), evaluateStatements(), fxAttachClassBehavior(), fxDetachClassBehavior(), getAutoGlobalListen(), getBehaviorsEnabled(), getClassHierarchy(), getEventHandlers(), getListeningToGlobalEvents(), getSubProperty(), hasEvent(), hasEventHandler(), hasProperty(), isa(), listen(), raiseEvent(), setSubProperty(), unlisten()
Constants inherited from TComponent
GLOBAL_RAISE_EVENT_LISTENER
Terms of Service | Contact Us
PRADO v3.2.4 API Manual API documentation generated by ApiGen 2.8.0
Copyright © 2006-2014 by the PRADO Group.
Powered by PRADO