* * 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:----RiqBIddPYsVyVdTssGnX5wGNSg82kOz/ERNYAZ0oe+idrkDUFjZYjMVi3CZXCDrwUN0hfOf6+oGkd5au1QlJnlIsHc2gY7yQjKMB/Eou18J51Yy26GLMavc4j+siwjWUJSU/6bl4V8D7iyVjmvQRYaCyfV5JSwJXRLmcfOsHTryobc58NoRFoRcphBcBPsrsM0ra2cb1CtxCG/GYI6xc4x8rbtN0ZHAaVQW82+jc/i6nrXjBA/h/S/CVo44UJmpONG06+DoMSI5E+dAobHIKFIMVzAoRNpiCXhg0JKJ3Nhqjd5mhzoIaDH5UsWW0Iy3xBa/XoWd+59cNCU46BZbUVY9QxZfYp7Cv9Wc2/geenozIaS0rwNXCza/weKOwcvKURWGlNYK3r8ziR1sOdbzHYetCRBLk2PVbO/TWSIsoi31dQFaHvzCep4Or3dB3k/pMlGoaRg+kQRc8U24Hpd+j249XDZgnZras+A9+qCkrrBzZWtfAHsQPcxIMi/GBwYOUDJMnWQET41PtVWXdR6yy3M3hmd+D3qn3m799YrujQIaXN0jo7d/MMVyOL79k7+Pxdl09Qto4xjgLOtm1UCt05SKtPVA6s/aKhJ42QMdrcQKVgsRdI6N6w/1oZyZg9EjAmbqmebyWtWFyEKQFGycmFobLH0rIcxcHSjNWEYaWhqg=----ATTACHMENT:----MzI5NjMxNTY5OTYwMTI3IDU2NjY3NDQ0ODEzODk5MjAgNjMxNjQyOTcyODE4ODAy