Skip to content

Commit

Permalink
[PageFlow] Moved the location of creating a PageFlow object into the …
Browse files Browse the repository at this point in the history
…PageFlowGenerator class. (Issue piece#4)
  • Loading branch information
iteman committed Sep 18, 2012
1 parent 34fc6f0 commit beb8e90
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/Piece/Flow/PageFlow/PageFlowFactory.php
Expand Up @@ -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;
}
Expand Down
9 changes: 4 additions & 5 deletions src/Piece/Flow/PageFlow/PageFlowGenerator.php
Expand Up @@ -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();
}

Expand Down Expand Up @@ -132,6 +129,8 @@ public function generate()
}

$this->pageFlow->setFSM($this->fsmBuilder->getFSM());

return $this->pageFlow;
}

/**
Expand Down

0 comments on commit beb8e90

Please sign in to comment.