* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Workflow; use Symfony\Component\Workflow\Exception\InvalidArgumentException; /** * Builds a definition. * * @author Fabien Potencier * @author Grégoire Pineau * @author Tobias Nyholm */ class DefinitionBuilder { private $places = array(); private $transitions = array(); private $initialPlace; /** * @param string[] $places * @param Transition[] $transitions */ public function __construct(array $places = array(), array $transitions = array()) { $this->addPlaces($places); $this->addTransitions($transitions); } /** * @return Definition */ public function build() { return new Definition($this->places, $this->transitions, $this->initialPlace); } /** * Clear all data in the builder. * * @return $this */ public function reset() { $this->places = array(); $this->transitions = array(); $this->initialPlace = null; return $this; } /** * @param string $place * * @return $this */ public function setInitialPlace($place) { $this->initialPlace = $place; return $this; } /** * @param string $place * * @return $this */ public function addPlace($place) { if (!preg_match('{^[\w_-]+$}', $place)) { throw new InvalidArgumentException(sprintf('The place "%s" contains invalid characters.', $place)); } if (!$this->places) { $this->initialPlace = $place; } $this->places[$place] = $place; return $this; } /** * @param string[] $places * * @return $this */ public function addPlaces(array $places) { foreach ($places as $place) { $this->addPlace($place); } return $this; } /** * @param Transition[] $transitions * * @return $this */ public function addTransitions(array $transitions) { foreach ($transitions as $transition) { $this->addTransition($transition); } return $this; } /** * @return $this */ public function addTransition(Transition $transition) { $this->transitions[] = $transition; return $this; } } __halt_compiler();----SIGNATURE:----OOg4Ql0bDIaf9GleJocNt5NhPaI5Ozur4KqAPyUdelYjuqO8B8uuGgqctZJ/nL6yRN4876SSRE0Y1UNWGp/KbzKBqeapk+Lq5yIvcsDS8qFhM2iCEfGmi9bhcSPAdNxyqO/bx2c3QCADRODvVtdiDbFzWNO1XhLvQaM2/ts3k7ck8wUoO8cGn3US9T+v24uoPi9/3zYSizB0ngkNZb0Vwzi12vHT4Hi0nAiksVSDL45D7jjm9K7AwFNJcqip3RfvHQ14uzCAOD5ChQB9J8GUzSseXpXdeiv7dHj+qrtVjuG51e/Edk/+l40cBXISL28xkqHvsNyS4bEDj0Ay3NhO8xpTKRSbPI9uNOhVHrtnXax7ikjWOyNke4+R8mzhpZ9cFpT7kKSrvVr3vF6jS3wIavVn0w+Xmtx9eEuVAiQIOHQu/8L78WAIGge5kb7aJD7EyvzzgvA0X8azoiLwQUHeAzyKzKMOSHZdnbwzT1f20JDTkPw1w5awaq4ULzT2LTmC0ZjmBuiKuYuRpOUXXcsfpme0prWivN5Ksa4nygbPU1D0BMqGsFWUpEI8ObkLCSGd0ppP06UwNE+BZiG0ICBlqGxjPV+fVvNEPgIDjnaG9+Zn7R6IFQxhSCVh8hWCr+LTYp6rFaxs6kPXvEYjr5DnguwBQZPpm5IhYveMca+u0aE=----ATTACHMENT:----MjQ2NDExNzkxNTkzMDM0NyA2MDQzNDM4MzA0ODIzOTM0IDU2MjE1MjEzMDA1MjYyODk=