function it_throws_exception_when_registering_an_operator_with_an_already_attributed_name(AbstractMassEditOperator $productOperator, AbstractMassEditOperator $anotherProductOperator) { $productOperator->getName()->willReturn('product'); $anotherProductOperator->getName()->willReturn('product'); $exception = new \LogicException('An operator with the name "product" is already registered'); $this->register('product-grid', $productOperator); $this->shouldThrow($exception)->duringRegister('another-product-grid', $anotherProductOperator); }
/** * Registers an operator inside a gridName index * * @param string $gridName * @param MassEditActionOperator $operator */ public function register($gridName, AbstractMassEditOperator $operator) { if (isset($this->operators[$gridName])) { throw new \InvalidArgumentException(sprintf('An operator with the alias "%s" is already registered', $gridName)); } if (in_array($operator->getName(), $this->names)) { throw new \LogicException(sprintf('An operator with the name "%s" is already registered', $operator->getName())); } $this->operators[$gridName] = $operator; $this->names[] = $operator->getName(); }
/** * @param SecurityFacade $securityFacade * @param EntityManager $manager */ public function __construct(Securityfacade $securityFacade, EntityManager $manager) { parent::__construct($securityFacade); $this->manager = $manager; }