Finite\StateMachine\StateMachine::getDispatcher PHP Method

getDispatcher() public method

public getDispatcher ( ) : Symfony\Component\EventDispatcher\EventDispatcherInterface
return Symfony\Component\EventDispatcher\EventDispatcherInterface
    public function getDispatcher()
    {
        return $this->dispatcher;
    }

Usage Example

コード例 #1
0
ファイル: CallbacksTest.php プロジェクト: Rioji/Finite
 protected function setUp()
 {
     $this->object = new \stdClass();
     $this->object->finiteState = null;
     $this->alternativeObject = new \stdClass();
     $this->alternativeObject->finiteState = null;
     $this->stateMachine = new StateMachine($this->object);
     $this->alternativeStateMachine = new StateMachine($this->alternativeObject, $this->stateMachine->getDispatcher());
     $this->callbacksMock = $this->getMockBuilder('\\stdClass')->setMethods(array('afterItWasProposed', 'afterItWasProposedOrReviewed', 'afterItWasAnythingButProposed', 'onReview', 'afterItLeavesReviewed'))->getMock();
     $states = array('draft' => array('type' => 'initial'), 'proposed' => array(), 'reviewed' => array(), 'published' => array('type' => 'final'), 'declined' => array('type' => 'final'));
     $transitions = array('propose' => array('from' => 'draft', 'to' => 'proposed'), 'return_to_draft' => array('from' => 'proposed', 'to' => 'draft'), 'review' => array('from' => 'proposed', 'to' => 'reviewed'), 'publish' => array('from' => 'reviewed', 'to' => 'published'), 'decline' => array('from' => array('proposed', 'reviewed'), 'to' => 'declined'));
     $loader = new ArrayLoader(array('states' => $states, 'transitions' => $transitions, 'callbacks' => array('after' => array(array('to' => 'proposed', 'do' => array($this->callbacksMock, 'afterItWasProposed')), array('to' => array('proposed', 'reviewed'), 'do' => array($this->callbacksMock, 'afterItWasProposedOrReviewed')), array('to' => array('-proposed'), 'do' => array($this->callbacksMock, 'afterItWasAnythingButProposed')), array('on' => 'review', 'do' => array($this->callbacksMock, 'onReview')), array('from' => 'reviewed', 'do' => array($this->callbacksMock, 'afterItLeavesReviewed'))))));
     $loader->load($this->stateMachine);
     $this->stateMachine->initialize();
     $alternativeLoader = new ArrayLoader(array('states' => $states, 'transitions' => $transitions));
     $alternativeLoader->load($this->alternativeStateMachine);
     $this->alternativeStateMachine->initialize();
 }