/** * @param string $name * * @return string * * @throws \LogicException */ public function getPermission($name) { if (!$this->hasPermission()) { throw new \LogicException('Current action does not require any authorization.'); } if (!$this->parameters->has('permission')) { return sprintf('%s.%s.%s', $this->metadata->getApplicationName(), $this->metadata->getName(), $name); } return $this->parameters->get('permission'); }
function it_throws_an_exception_when_trying_to_retrieve_undefined_grid(Parameters $parameters) { $parameters->has('grid')->willReturn(false); $this->shouldThrow(\LogicException::class)->during('getGrid'); }
function it_throws_an_exception_when_permission_is_set_as_false_in_parameters_but_still_trying_to_get_it(Parameters $parameters) { $parameters->has('permission')->willReturn(true); $parameters->get('permission')->willReturn(false); $this->shouldThrow(\LogicException::class)->during('getPermission', ['index']); }
function it_can_have_state_machine_transition(Parameters $parameters) { $parameters->has('state_machine')->willReturn(false); $this->hasStateMachine()->shouldReturn(false); $parameters->has('state_machine')->willReturn(true); $parameters->get('state_machine[graph]', null, true)->willReturn('sylius_product_review_state'); $parameters->get('state_machine[transition]', null, true)->willReturn('approve'); $this->hasStateMachine()->shouldReturn(true); $this->getStateMachineGraph()->shouldReturn('sylius_product_review_state'); $this->getStateMachineTransition()->shouldReturn('approve'); }
/** * @return bool */ public function hasStateMachine() { return $this->parameters->has('state_machine'); }
/** * @return bool */ public function hasGrid() { return $this->parameters->has('grid'); }