forked from piece/piece-flow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Continuation][PageFlow] introduced the event system to dispatch syst…
…em events to listeners (Issue piece#4)
- Loading branch information
Showing
4 changed files
with
78 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
/** | ||
* PHP version 5.3 | ||
* | ||
* Copyright (c) 2006-2008, 2012 KUBO Atsuhiro <[email protected]>, | ||
* Copyright (c) 2006-2008, 2012-2013 KUBO Atsuhiro <[email protected]>, | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
|
@@ -29,21 +29,23 @@ | |
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* @package Piece_Flow | ||
* @copyright 2006-2008, 2012 KUBO Atsuhiro <[email protected]> | ||
* @copyright 2006-2008, 2012-2013 KUBO Atsuhiro <[email protected]> | ||
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License | ||
* @version Release: @package_version@ | ||
* @since File available since Release 1.14.0 | ||
*/ | ||
|
||
namespace Piece\Flow\Continuation; | ||
|
||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
|
||
use Piece\Flow\PageFlow\ActionInvokerInterface; | ||
|
||
/** | ||
* The continuation server. | ||
* | ||
* @package Piece_Flow | ||
* @copyright 2006-2008, 2012 KUBO Atsuhiro <[email protected]> | ||
* @copyright 2006-2008, 2012-2013 KUBO Atsuhiro <[email protected]> | ||
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License | ||
* @version Release: @package_version@ | ||
* @since Class available since Release 1.14.0 | ||
|
@@ -65,6 +67,12 @@ class ContinuationServer | |
*/ | ||
protected $continuationContextProvider; | ||
|
||
/** | ||
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface | ||
* @since Property available since Release 2.0.0 | ||
*/ | ||
protected $eventDispatcher; | ||
|
||
/** | ||
* @var \Piece\Flow\Continuation\PageFlowInstance | ||
* @since Property available since Release 2.0.0 | ||
|
@@ -178,6 +186,15 @@ public function setContinuationContextProvider(ContinuationContextProvider $cont | |
$this->continuationContextProvider = $continuationContextProvider; | ||
} | ||
|
||
/** | ||
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher | ||
* @since Method available since Release 2.0.0 | ||
*/ | ||
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher) | ||
{ | ||
$this->eventDispatcher = $eventDispatcher; | ||
} | ||
|
||
/** | ||
* @return \Piece\Flow\Continuation\PageFlowInstance | ||
* @since Method available since Release 2.0.0 | ||
|
@@ -267,6 +284,7 @@ protected function createPageFlowInstance($payload) | |
|
||
$pageFlowInstance->setActionInvoker($this->actionInvoker); | ||
$pageFlowInstance->setPayload($payload); | ||
$pageFlowInstance->setEventDispatcher($this->eventDispatcher); | ||
|
||
return $pageFlowInstance; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
/** | ||
* PHP version 5.3 | ||
* | ||
* Copyright (c) 2006-2008, 2012 KUBO Atsuhiro <[email protected]>, | ||
* Copyright (c) 2006-2008, 2012-2013 KUBO Atsuhiro <[email protected]>, | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
|
@@ -29,22 +29,24 @@ | |
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* @package Piece_Flow | ||
* @copyright 2006-2008, 2012 KUBO Atsuhiro <[email protected]> | ||
* @copyright 2006-2008, 2012-2013 KUBO Atsuhiro <[email protected]> | ||
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License | ||
* @version Release: @package_version@ | ||
* @since File available since Release 1.14.0 | ||
*/ | ||
|
||
namespace Piece\Flow\Continuation; | ||
|
||
use Symfony\Component\EventDispatcher\EventDispatcher; | ||
|
||
use Piece\Flow\PageFlow\EventContext; | ||
use Piece\Flow\PageFlow\PageFlowCacheFactory; | ||
use Piece\Flow\PageFlow\PageFlowRegistry; | ||
use Piece\Flow\PageFlow\PageFlowRepository; | ||
|
||
/** | ||
* @package Piece_Flow | ||
* @copyright 2006-2008, 2012 KUBO Atsuhiro <[email protected]> | ||
* @copyright 2006-2008, 2012-2013 KUBO Atsuhiro <[email protected]> | ||
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License | ||
* @version Release: @package_version@ | ||
* @since Class available since Release 1.14.0 | ||
|
@@ -114,6 +116,7 @@ public function startsPageFlowInstancesForAnExclusivePageFlow() | |
$continuationServer = new ContinuationServer($pageFlowInstanceRepository); | ||
$continuationServer->setActionInvoker($this->createCounterActionInvoker()); | ||
$continuationServer->setContinuationContextProvider($this->continuationContextProvider); | ||
$continuationServer->setEventDispatcher(new EventDispatcher()); | ||
|
||
$this->pageFlowID = 'Counter'; | ||
$this->eventID = null; | ||
|
@@ -146,6 +149,7 @@ public function startsPageFlowInstancesForANonExclusivePageFlow() | |
$continuationServer = new ContinuationServer($pageFlowInstanceRepository); | ||
$continuationServer->setActionInvoker($this->createCounterActionInvoker()); | ||
$continuationServer->setContinuationContextProvider($this->continuationContextProvider); | ||
$continuationServer->setEventDispatcher(new EventDispatcher()); | ||
|
||
$this->pageFlowID = 'Counter'; | ||
$this->eventID = null; | ||
|
@@ -179,6 +183,7 @@ public function startsPageFlowInstancesForMultiplePageFlows() | |
$continuationServer = new ContinuationServer($pageFlowInstanceRepository); | ||
$continuationServer->setActionInvoker($this->createCounterActionInvoker()); | ||
$continuationServer->setContinuationContextProvider($this->continuationContextProvider); | ||
$continuationServer->setEventDispatcher(new EventDispatcher()); | ||
|
||
$this->pageFlowID = 'Counter'; | ||
$this->eventID = null; | ||
|
@@ -211,6 +216,7 @@ public function continuesAPageFlowInstance() | |
$continuationServer = new ContinuationServer($pageFlowInstanceRepository); | ||
$continuationServer->setActionInvoker($this->createCounterActionInvoker()); | ||
$continuationServer->setContinuationContextProvider($this->continuationContextProvider); | ||
$continuationServer->setEventDispatcher(new EventDispatcher()); | ||
|
||
$this->pageFlowID = 'Counter'; | ||
$this->eventID = null; | ||
|
@@ -242,6 +248,7 @@ public function raisesAnExceptionWhenAnUnexpectedPageFlowIdIsSpecifiedForTheSeco | |
$continuationServer = new ContinuationServer($pageFlowInstanceRepository); | ||
$continuationServer->setActionInvoker($this->createCounterActionInvoker()); | ||
$continuationServer->setContinuationContextProvider($this->continuationContextProvider); | ||
$continuationServer->setEventDispatcher(new EventDispatcher()); | ||
|
||
$this->pageFlowID = 'Counter'; | ||
$this->eventID = null; | ||
|
@@ -270,6 +277,7 @@ public function findsThePageFlowInstanceByAPageFlowId($exclusive) | |
$continuationServer = new ContinuationServer($pageFlowInstanceRepository); | ||
$continuationServer->setActionInvoker($this->createCounterActionInvoker()); | ||
$continuationServer->setContinuationContextProvider($this->continuationContextProvider); | ||
$continuationServer->setEventDispatcher(new EventDispatcher()); | ||
|
||
$this->pageFlowID = 'Counter'; | ||
$this->eventID = null; | ||
|
@@ -310,6 +318,7 @@ public function raisesAnExceptionWhenThePageFlowInstanceHasExpired($expirationTi | |
$continuationServer = new ContinuationServer($pageFlowInstanceRepository, new GC($expirationTime, $clock)); | ||
$continuationServer->setActionInvoker(\Phake::mock('Piece\Flow\PageFlow\ActionInvokerInterface')); | ||
$continuationServer->setContinuationContextProvider($this->continuationContextProvider); | ||
$continuationServer->setEventDispatcher(new EventDispatcher()); | ||
|
||
$this->pageFlowID = 'Counter'; | ||
$this->eventID = null; | ||
|
@@ -358,6 +367,7 @@ public function validatesTheLastReceivedEvent() | |
$continuationServer = new ContinuationServer($pageFlowInstanceRepository); | ||
$continuationServer->setActionInvoker($this->createCounterActionInvoker()); | ||
$continuationServer->setContinuationContextProvider($this->continuationContextProvider); | ||
$continuationServer->setEventDispatcher(new EventDispatcher()); | ||
|
||
$this->pageFlowID = 'CheckLastEvent'; | ||
$this->eventID = 'nonExistingEvent'; | ||
|