* * 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; use Symfony\Component\Workflow\SupportStrategy\ClassInstanceSupportStrategy; use Symfony\Component\Workflow\SupportStrategy\SupportStrategyInterface; /** * @author Fabien Potencier * @author Grégoire Pineau */ class Registry { private $workflows = array(); /** * @param Workflow $workflow * @param string|SupportStrategyInterface $supportStrategy */ public function add(Workflow $workflow, $supportStrategy) { if (!$supportStrategy instanceof SupportStrategyInterface) { @trigger_error('Support of class name string was deprecated after version 3.2 and won\'t work anymore in 4.0.', E_USER_DEPRECATED); $supportStrategy = new ClassInstanceSupportStrategy($supportStrategy); } $this->workflows[] = array($workflow, $supportStrategy); } /** * @param object $subject * @param string|null $workflowName * * @return Workflow */ public function get($subject, $workflowName = null) { $matched = null; foreach ($this->workflows as list($workflow, $supportStrategy)) { if ($this->supports($workflow, $supportStrategy, $subject, $workflowName)) { if ($matched) { throw new InvalidArgumentException('At least two workflows match this subject. Set a different name on each and use the second (name) argument of this method.'); } $matched = $workflow; } } if (!$matched) { throw new InvalidArgumentException(sprintf('Unable to find a workflow for class "%s".', get_class($subject))); } return $matched; } private function supports(Workflow $workflow, $supportStrategy, $subject, $workflowName) { if (null !== $workflowName && $workflowName !== $workflow->getName()) { return false; } return $supportStrategy->supports($workflow, $subject); } } __halt_compiler();----SIGNATURE:----M525surqqNGgTEHHEz7CBSceC4pZaGV7JDO3OMJipaIKX3J6nKBEYjY170RMdYRPDzY8wAEVpgyudTGvp0H/SdJbC2S2ooYN3m5o5VOJ1bMsusDax8dmjcvMEdLyoai9rdDnIJmcRabAecWR9L5hhwrUw3IA+SM7SPcfI9y2FcQ0ValVs23jsgSjnRyLF1obR3enAf2Hr3zdTy2qDDjR+FzUaIZchGwkvuLHxsDVp88w+obP+a21P+QjVQf+3OTUv74MHQbnU/4efiARH8clevbQOPOhq4xB7ylChnombiU/T//eoZ67XgJLHXL7d0nsjdFl8hC2+AbOn6NgXTMGJXRGtGI9T6SJgqryuoYczKU6POHr6a1th1wPLTkxBTHzTQQW6k00yqtjWYsx0PvR/7ygtkr1ZawWr3DHx+ApvEQVSEFw8+RW4XLow40LGy9ggB0ym55qwDZKmAiCWom5nBUro28yQsOyNr72hw5w255W6hUgcWBHxlO4qCbDUUsWNeHMY70PsT8o/Knfmga8T61qj+6XuEc5M2TS8MCDCbHOYiJRGMc7IrIoOuKVGnlbmuEqUgV/hQ0x+aMAf683afoVcqWA3K1oC10iakfOhmbhIzJE0sALwHclDoYg+AAFIJetcAXxRj64ze1ce3ovkyZuTR4mJIhldFbew+ArUe0=----ATTACHMENT:----NjUxMjM4NjUzNjMyMTQ4OSA5NjIyNDI4MTg0NDY2NDgxIDcwODQ3MzgxMzczNzYw