Skip to content

Commit

Permalink
[PageFlow] changed the PageFlowGenerator::__construct() method to rec…
Browse files Browse the repository at this point in the history
…eive any PageFlowInterface object as well as the page flow ID (Issue piece#4)
  • Loading branch information
iteman committed Aug 22, 2013
1 parent 08bfbc0 commit d14ea34
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
12 changes: 6 additions & 6 deletions src/Piece/Flow/PageFlow/PageFlowFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/**
* PHP version 5.3
*
* Copyright (c) 2012 KUBO Atsuhiro <[email protected]>,
* Copyright (c) 2012-2013 KUBO Atsuhiro <[email protected]>,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand All @@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* @package Piece_Flow
* @copyright 2012 KUBO Atsuhiro <[email protected]>
* @copyright 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 2.0.0
Expand All @@ -39,7 +39,7 @@

/**
* @package Piece_Flow
* @copyright 2012 KUBO Atsuhiro <[email protected]>
* @copyright 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 2.0.0
Expand All @@ -60,12 +60,12 @@ public function __construct(PageFlowRegistry $pageFlowRegistry)
}

/**
* @param string $id
* @return \Piece\Flow\PageFlow\PageFlow
* @param string $id
* @return \Piece\Flow\PageFlow\PageFlowInterface
*/
public function create($id)
{
$pageFlowGenerator = new PageFlowGenerator($id, $this->pageFlowRegistry);
$pageFlowGenerator = new PageFlowGenerator(new PageFlow($id), $this->pageFlowRegistry);

return $pageFlowGenerator->generate();
}
Expand Down
32 changes: 15 additions & 17 deletions src/Piece/Flow/PageFlow/PageFlowGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
*/
class PageFlowGenerator
{
/**
* @var \Piece\Flow\PageFlow\PageFlowInterface
* @since Property available since Release 2.0.0
*/
protected $pageFlow;

/**
* @var \Piece\Flow\PageFlow\PageFlowRegistry
* @since Property available since Release 2.0.0
Expand All @@ -71,13 +77,14 @@ class PageFlowGenerator
protected $stateMachineBuilder;

/**
* @param string $id
* @param \Piece\Flow\PageFlow\PageFlowRegistry $pageFlowRegistry
* @param \Piece\Flow\PageFlow\PageFlowInterface $pageFlow
* @param \Piece\Flow\PageFlow\PageFlowRegistry $pageFlowRegistry
*/
public function __construct($id, PageFlowRegistry $pageFlowRegistry)
public function __construct(PageFlowInterface $pageFlow, PageFlowRegistry $pageFlowRegistry)
{
$this->pageFlow = $pageFlow;
$this->pageFlowRegistry = $pageFlowRegistry;
$this->stateMachineBuilder = new StateMachineBuilder(new PageFlow($id));
$this->stateMachineBuilder = new StateMachineBuilder($this->pageFlow);
}

/**
Expand Down Expand Up @@ -134,7 +141,7 @@ public function generate()
$this->configureViewStates($definition['viewState']);
$this->configureActionStates($definition['actionState']);

return $this->getPageFlow();
return $this->pageFlow;
}

/**
Expand Down Expand Up @@ -223,7 +230,7 @@ protected function wrapAction(array $action = null)
$actionID = $action['class'] . ':' . $action['method'];
}

return array(new EventHandler($actionID, $this->getPageFlow()), 'invokeAction');
return array(new EventHandler($actionID, $this->pageFlow), 'invokeAction');
}

/**
Expand Down Expand Up @@ -257,7 +264,7 @@ protected function wrapEventTriggerAction(array $action = null)
$actionID = $action['class'] . ':' . $action['method'];
}

return array(new EventHandler($actionID, $this->getPageFlow()), 'invokeActionAndTriggerEvent');
return array(new EventHandler($actionID, $this->pageFlow), 'invokeActionAndTriggerEvent');
}

/**
Expand All @@ -270,7 +277,7 @@ protected function readDefinition()

return $processor->processConfiguration(
new Definition17Configuration(),
array('definition17' => Yaml::parse($this->pageFlowRegistry->getFileName($this->getPageFlow()->getID())))
array('definition17' => Yaml::parse($this->pageFlowRegistry->getFileName($this->pageFlow->getID())))
);
}

Expand All @@ -285,15 +292,6 @@ protected function addState(StateInterface $state)
$state->setDoEvent(new DoEvent());
$this->stateMachineBuilder->getStateMachine()->addState($state);
}

/**
* @return \Piece\Flow\PageFlow\PageFlowInterface
* @since Method available since Release 2.0.0
*/
protected function getPageFlow()
{
return $this->stateMachineBuilder->getStateMachine();
}
}

/*
Expand Down

0 comments on commit d14ea34

Please sign in to comment.