org-puremvc-php-multicore-utilities-statemachine
[ class tree: org-puremvc-php-multicore-utilities-statemachine ] [ index: org-puremvc-php-multicore-utilities-statemachine ] [ all elements ]

Class: FSMInjector

Source Location: /org/puremvc/php/multicore/utilities/statemachine/FSMInjector.php

Class Overview

Notifier
   |
   --FSMInjector

Creates and registers a StateMachine described in XML.


Author(s):

Variables

Methods



Class Details

[line 76]
Creates and registers a StateMachine described in XML.

This allows reconfiguration of the StateMachine without changing any code, as well as making it easier than creating all the State instances and registering them with the StateMachine at startup time.

One way to acheive this setup is to use a command controller that could be added a application startup. Such a controller could look like this:

  1.  //From the PureMVC AS3 StopWatch Demo
  2.  class InjectFSMCommand extends SimpleCommand
  3.  {
  4.      public function execute INotification $notification )
  5.      {
  6.          // Create the FSM definition
  7.          $fsmStr = <<<XML
  8.          <fsm initial="StopWatch/states/ready">
  9.              <state name="StopWatch/states/ready" entering="resetDisplay">
  10.                  <transition action="StopWatch/actions/start" target="StopWatch/states/running"/>
  11.              </state>
  12.              <state name="StopWatch/states/running" entering="ensureTimer">
  13.                  <transition action="StopWatch/actions/split" target="StopWatch/states/paused"/>
  14.                  <transition action="StopWatch/actions/stop" target="StopWatch/states/stopped"/>
  15.              </state>
  16.              <state name="StopWatch/states/paused" entering="freezeDisplay">
  17.                  <transition action="StopWatch/actions/unsplit" target="StopWatch/states/running"/>
  18.                  <transition action="StopWatch/actions/stop" target="StopWatch/states/stopped"/>
  19.              </state>
  20.              <state name="StopWatch/states/stopped" entering="stopTimer">
  21.                  <transition action="StopWatch/actions/reset" target="StopWatch/states/ready"/>
  22.              </state>
  23.          </fsm>XML;
  24.  
  25.          $fsm = new SimpleXMLElement($fsmStr);
  26.  
  27.          $injector = new FSMInjector($fsm);
  28.          $injector->initializeNotifier('FSMInjectorTest');
  29.          $injector->inject();
  30.      }
  31.  }




Tags:

see:  StateMachine
see:  State


[ Top ]


Class Variables

$fsm =

[line 82]

The XML FSM definition



Tags:

access:  protected

Type:   SimpleXMLElement


[ Top ]

$stateList =  null

[line 88]

The List of State objects



Tags:

access:  protected

Type:   array


[ Top ]



Class Methods


constructor __construct [line 96]

FSMInjector __construct( $fsm)

Constructor.



Tags:

access:  public


Parameters:

SimpleXMLElement   $fsm   The XML FSM definition

[ Top ]

method createState [line 156]

State createState( $stateDef)

Creates a State instance from its XML definition.



Tags:

access:  protected


Parameters:

SimpleXMLElement   $stateDef  

[ Top ]

method getStates [line 133]

array getStates( )

Get the state definitions.

Creates and returns the array of State objects from the FSM on first call, subsequently returns the existing array.




Tags:

access:  protected


[ Top ]

method inject [line 109]

void inject( )

Inject the StateMachine into the PureMVC apparatus.

Creates the StateMachine instance, registers all the states and registers the StateMachine with the IFacade.




Tags:

access:  public


[ Top ]

method isInitial [line 180]

bool isInitial( string $stateName)

Is the given state the initial state?



Tags:

access:  protected


Parameters:

string   $stateName  

[ Top ]


Documentation generated on Mon, 03 Aug 2009 05:20:48 +0000 by phpDocumentor 1.4.2