diff --git a/src/Piece/Flow/PageFlow/PageFlowFactory.php b/src/Piece/Flow/PageFlow/PageFlowFactory.php index 0f2a9c2..b854bb2 100644 --- a/src/Piece/Flow/PageFlow/PageFlowFactory.php +++ b/src/Piece/Flow/PageFlow/PageFlowFactory.php @@ -53,10 +53,9 @@ class PageFlowFactory */ public function create($definitionFile, ActionInvoker $actionInvoker) { - $pageFlow = new PageFlow(); + $pageFlowGenerator = new PageFlowGenerator($definitionFile); + $pageFlow = $pageFlowGenerator->generate(); $pageFlow->setActionInvoker($actionInvoker); - $pageFlowGenerator = new PageFlowGenerator($pageFlow, $definitionFile); - $pageFlowGenerator->generate(); return $pageFlow; } diff --git a/src/Piece/Flow/PageFlow/PageFlowGenerator.php b/src/Piece/Flow/PageFlow/PageFlowGenerator.php index 02ba863..a911c9e 100644 --- a/src/Piece/Flow/PageFlow/PageFlowGenerator.php +++ b/src/Piece/Flow/PageFlow/PageFlowGenerator.php @@ -72,20 +72,17 @@ class PageFlowGenerator protected $definitionFile; /** - * Sets a PageFlow object to the property. - * - * @param \Piece\Flow\PageFlow\PageFlow $pageFlow * @param string $definitionFile * @throws \Piece\Flow\PageFlow\FileNotFoundException */ - public function __construct(PageFlow $pageFlow, $definitionFile) + public function __construct($definitionFile) { if (!file_exists($definitionFile)) { throw new FileNotFoundException(sprintf('The flow definition file [ %s ] is not found.', $definitionFile)); } $this->definitionFile = $definitionFile; - $this->pageFlow = $pageFlow; + $this->pageFlow = new PageFlow(); $this->fsmBuilder = new FSMBuilder(); } @@ -132,6 +129,8 @@ public function generate() } $this->pageFlow->setFSM($this->fsmBuilder->getFSM()); + + return $this->pageFlow; } /**