/** * {@inheritdoc} */ public function setConfiguration(ConfigurationInterface $configuration) { $this->configuration = $configuration; $resolver = new OptionsResolver(); $this->setDefaultOptions($resolver); $this->eventManager->dipatchConfigureEvent($this, $resolver); $this->options = $resolver->resolve($configuration->getActionOptions($this->getType())); }
public function it_displays_forms(ManagerInterface $manager, ActionEventManager $eventManager, ConfigurationInterface $configuration, Request $request, Entity $object, EngineInterface $templating, FormView $formView, Response $response) { $request->isMethod('post')->willReturn(false); $manager->find('entity_class', 'id', [])->willReturn($object); $object->getId()->willReturn('id'); $configuration->getActionOptions('edit')->willReturn(['form_type' => 'form_type']); $configuration->hasAction('delete')->willReturn(false); $templating->renderResponse('PimCustomEntityBundle:CustomEntity:form.html.twig', ['form' => $formView, 'formAction' => 'pim_customentity_edit?&customEntityName=entity&id=id', 'customEntityName' => 'entity', 'baseTemplate' => 'PimCustomEntityBundle::layout.html.twig', 'indexUrl' => 'index?&ir_param1=value1', 'pre_render' => true])->willReturn($response); $this->initializeEventManager($eventManager); $this->setConfiguration($configuration); $this->execute($request)->shouldReturn($response); }
public function testObjectRemoval(ManagerInterface $manager, ActionEventManager $eventManager, ConfigurationInterface $configuration, Request $request, $options, $findOptions) { $object = new \stdClass(); $configuration->getActionOptions('delete')->willReturn($options); $this->setConfiguration($configuration); $manager->find('entity_class', 'id', $findOptions)->willReturn($object); $manager->remove($object)->shouldBeCalled(); $this->initializeEventManager($eventManager); $response = $this->execute($request, $configuration); $response->shouldHaveType('Symfony\\Component\\HttpFoundation\\Response'); $response->getStatusCode()->shouldReturn(204); }
public function it_supports_options(ActionFactory $actionFactory, ActionEventManager $eventManager, ConfigurationInterface $configuration, Request $request, EngineInterface $templating, ActionInterface $createAction, Response $response) { $configuration->getActionOptions('index')->willReturn(['quick_create' => true, 'template' => 'template', 'base_template' => 'base_template']); $configuration->hasAction('create')->willReturn(true); $actionFactory->getAction('entity', 'create')->willReturn($createAction); $createAction->getRoute()->willReturn('create_route'); $createAction->getRouteParameters(null)->willReturn(['cr_param1' => 'value1']); $templating->renderResponse('template', ['createUrl' => 'create_route?&cr_param1=value1', 'quickCreate' => true, 'customEntityName' => 'entity', 'baseTemplate' => 'base_template', 'indexUrl' => 'pim_customentity_index?&customEntityName=entity', 'pre_render' => true])->willReturn($response); $this->initializeEventManager($eventManager); $this->setConfiguration($configuration); $this->execute($request)->shouldReturn($response); }
public function it_accepts_a_limit(ActionFactory $actionFactory, AbstractAction $indexAction, Request $request, ConfigurationInterface $configuration, ActionEventManager $eventManager, FlashBag $flashBag) { $actionFactory->getAction('entity', 'index')->willReturn($indexAction); $indexAction->getRoute()->willReturn('index_route'); $indexAction->getRouteParameters(null)->willReturn([]); $this->initializeEventManager($eventManager); $configuration->getActionOptions('quick_export')->willReturn(['limit' => 2]); $this->setConfiguration($configuration); $response = $this->execute($request); $response->shouldHaveType('Symfony\\Component\\HttpFoundation\\RedirectResponse'); $response->getTargetUrl()->shouldReturn('index_route?'); $flashBag->add('error', '<pim_custom_entity.export.limit_exceeded>%limit%=2;')->shouldBeCalled(); }
public function it_accepts_redirection_options(ManagerInterface $manager, ActionEventManager $eventManager, ConfigurationInterface $configuration, Request $request, Entity $object, FormFactoryInterface $formFactory, FormInterface $form, FlashBagInterface $flashBag) { $request->isMethod('post')->willReturn(true); $form->submit($request)->shouldBeCalled(); $form->isValid()->willReturn(true); $manager->create('entity_class', [], [])->willReturn($object); $manager->save($object, [])->shouldBeCalled(); $object->getId()->willReturn(null); $formFactory->create('form_type', $object, ['f_param1' => 'value1', 'data_class' => 'entity_class'])->shouldBeCalled()->willReturn($form); $configuration->getActionOptions('create')->willReturn(['form_type' => 'form_type', 'form_options' => ['f_param1' => 'value1'], 'redirect_route' => 'redirect_route', 'redirect_route_parameters' => ['c_r_param1' => 'value1'], 'success_message' => 'success_message']); $configuration->hasAction('delete')->willReturn(false); $flashBag->add('success', '<success_message>')->shouldBeCalled(); $this->initializeEventManager($eventManager); $this->setConfiguration($configuration); $response = $this->execute($request); $response->shouldHaveType('Symfony\\Component\\HttpFoundation\\RedirectResponse'); $response->getTargetUrl()->shouldReturn('redirect_route?&c_r_param1=value1'); }