/** * @param ContextInterface $context * * @throws ExecutionFailedException if some processor fired an exception */ protected function executeProcessors(ContextInterface $context) { $processors = $this->processorBag->getProcessors($context); /** @var ProcessorInterface $processor */ foreach ($processors as $processor) { try { $processor->process($context); } catch (\Exception $e) { throw new ExecutionFailedException($processors->getProcessorId(), $processors->getAction(), $processors->getGroup(), $e); } } }
public function testMinEndingCommonProcessorPriority() { $this->processorBag->addGroup('group1', 'action1'); $this->processorBag->addProcessor('processor1', [], 'action1', 'group1'); $this->processorBag->addProcessor('processor2', [], null, null, -256); $context = new Context(); $context->setAction('action1'); $this->processorBag->getProcessors($context); }
public function testGroupRangeApplicableCheckerWithLastGroupOnly() { $context = new Context(); $context->setAction('action1'); $context->setLastGroup('group5'); $processorBag = new ProcessorBag($this->getProcessorFactory()); $processorBag->addGroup('group1', 'action1', -10); $processorBag->addGroup('group2', 'action1', -20); $processorBag->addGroup('group4', 'action1', -30); $processorBag->addGroup('group3', 'action1', -40); $processorBag->addGroup('group5', 'action1', -50); $processorBag->addGroup('group6', 'action1', -60); $processorBag->addProcessor('processor1_no_action', []); $processorBag->addProcessor('processor2_no_action', [], null, null, -65536); $processorBag->addProcessor('processor1_no_group', [], 'action1'); $processorBag->addProcessor('processor2_no_group', [], 'action1', null, -65280); $processorBag->addProcessor('processor1', [], 'action1', 'group1'); $processorBag->addProcessor('processor2', [], 'action1', 'group2'); $processorBag->addProcessor('processor3', [], 'action1', 'group3'); $processorBag->addProcessor('processor4', [], 'action1', 'group4'); $processorBag->addProcessor('processor5', [], 'action1', 'group5'); $processorBag->addProcessor('processor6', [], 'action1', 'group6'); $this->assertProcessors(['processor1_no_action', 'processor1_no_group', 'processor1', 'processor2', 'processor4', 'processor3', 'processor5', 'processor2_no_group', 'processor2_no_action'], $processorBag->getProcessors($context)); }