Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version. Compare with Current  |   View Page History

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

Zend Framework: Zend_Event Component Proposal

Proposed Component Name Zend_Event
Developer Notes http://framework.zend.com/wiki/display/ZFDEV/Zend_Event
Proposers Alvar Vilu
Zend Liaison TBD
Revision 1.0 - 2 December 2009: Initial Draft. (wiki revision: 14)

Table of Contents

1. Overview

Zend_Event is AS3'like powerful event system.

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

  • Any event dispatchable component must extend Zend_Event_Dispatcher or implement Zend_Event_Dispatcher_Interface.

4. Dependencies on Other Framework Components

  • Zend_Exception

5. Theory of Operation

This component can handle event listeners per obj or via stack trace.

6. Milestones / Tasks

Describe some intermediate state of this component in terms of design notes, additional material added to this page, and / code. Note any significant dependencies here, such as, "Milestone #3 can not be completed until feature Foo has been added to ZF component XYZ." Milestones will be required for acceptance of future proposals. They are not hard, and many times you will only need to think of the first three below.

  • Milestone 1: design notes will be published here
  • Milestone 2: Working prototype checked into the incubator supporting use cases #1, #2, ...
  • Milestone 3: Working prototype checked into the incubator supporting use cases #3 and #4.
  • Milestone 4: Unit tests exist, work, and are checked into SVN.
  • Milestone 5: Initial documentation exists.

If a milestone is already done, begin the description with "[DONE]", like this:

  • Milestone #: [DONE] Unit tests ...

7. Class Index

  • Zend_Magic_Exception
  • Zend_Magic (factory class)
  • Zend_Magic_MindProbe
  • Zend_Magic_MindProbe_Intent
  • Zend_Magic_Action
  • Zend_Magic_CodeGen

8. Use Cases

UC-01
UC-01

9. Class Skeletons

/**

  • @see Zend_Event_Phase
    */
    require_once 'AVlib/Event/Phase.php';

/**

  • @author Alvar Vilu <alvar.vilu@msn.com>
    *
  • @property-read obj $target Event target object
  • @property-read string $type Event type
  • @property-read bool $bubbles Will event bubble?
  • @property-read obj $currentTarget Event receiver object
  • @property-read bool $cancelable Can stop event propagation?
  • @property-read int $eventPhase Current event phase
  • @property-read bool $stopPropagation Stops event propagation on another branch
  • @property-read bool $stopImmediatePropagation Stops propagation immediately
    */
    class Zend_Event
    {

/**

  • Event: close
  • @var string
    */
    const CLOSE = 'close';

/**

  • Event: open
  • @var string
    */
    const OPEN = 'open';

/**

  • Event: loaded
  • @var string
    */
    const LOADED = 'loaded';

/**

  • Will event bubbles back to (main)
  • @var bool
    */
    protected $_bubbles = false;

/**

  • Can something stop event propagation
  • @var bool
    */
    protected $_cancelable = false;

/**

  • Target where the event dispatcher currently dispatch
  • @var obj
    */
    protected $_currentTarget;

/**

  • Event current phase
  • @see Zend_Event_Phase
  • @var int
    */
    protected $_eventPhase = 0;

/**

  • If cancelable and this set true, progagation will immediately stop
  • @var bool
    */
    protected $_stopImmediatePropagation = false;

/**

  • If cancelable and this set true, propagation will stop after that obj level
  • @var bool
    */
    protected $_stopPropagation = false;

/**

  • Object that dispatches the event
  • @var obj
    */
    protected $_target;

/**

  • A constant string that indicates the type of event
  • @var string
    */
    protected $_type;

/**

  • @param string $type
  • @param bool $bubbles
  • @param bool $cancelable
  • @return Zend_Event
    */
    public function __construct ( $type, $bubbles = false, $cancelable = false )
    Unknown macro: { $this->_type = ( string ) $type; $this->_bubbles = ( bool ) $bubbles; $this->_cancelable = ( bool ) $cancelable; }

/**

  • Get read-only parameters
  • @param string $name
  • @throws Zend_Event_Exception If event parameter not readable.
  • @return mixed
    */
    final public function __get ( $name ) {

switch ( $name )

Unknown macro: { case 'bubbles'}

}

/**

  • Set writeable parameters
  • @param string $name
  • @param mixed $value
  • @throws Zend_Event_Exception If event parameter not writable.
  • @return mixed
    */
    public function __set ( $name, $value )
    Unknown macro: { require_once 'AVlib/Event/Exception.php'; throw new Zend_Event_Exception ( 'Event parameter not writable}

/**

  • Format event to a pretty string.
  • @return string
    */
    public function toString ( )
    Unknown macro: { return 'Zend_Event, type}

final public function __toString ( )

Unknown macro: { return $this->toString ( ); }

/**

  • @param int $eventPhase
  • @param obj $target
  • @param obj $currentTarget
  • @return Zend_Event
    */
    public function cloneEvent ( $eventPhase, $target, $currentTarget )
    Unknown macro: { $evt = clone $this; $evt->_eventPhase = $eventPhase; $evt->_target = $target; $evt->_currentTarget = $currentTarget; return $evt; }

/**

  • Clone should only be available inside of event
    */
    final protected function __clone ( ) {}

/**

  • Stops event propagation on another branch
  • @return Zend_Event
    */
    final public function stopPropagation ( )
    Unknown macro: { if ( $this->_cancelable ) $this->_stopPropagation = true; return $this; }

/**

  • Stops event propagation immediately
  • @return Zend_Event
    */
    final public function stopImmediatePropagation ( )
    Unknown macro: { if ( $this->_cancelable ) $this->_stopImmediatePropagation = true; return $this; }

}

]]></ac:plain-text-body></ac:macro>

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.