/** * Sets the source in the config * * @param \Oro\Bundle\DataGridBundle\Datagrid\Common\DatagridConfiguration $datagridConfig * @param \Pim\Bundle\CustomEntityBundle\Action\ActionInterface $indexAction */ protected function setSource(DatagridConfiguration $datagridConfig, ActionInterface $indexAction) { $customEntityConfig = $indexAction->getConfiguration(); $options = $indexAction->getOptions(); $sourceOptions = ($datagridConfig->offsetGetByPath('[source]') ?: []) + ['entity' => $customEntityConfig->getEntityClass(), 'type' => 'pim_custom_entity']; if (isset($options['acl'])) { $sourceOptions['acl_resource'] = $options['acl']; } $datagridConfig->offsetSetByPath('[source]', $sourceOptions); }
public function it_configures_mass_actions(BuildBefore $event, DatagridConfiguration $datagridConfig, ActionInterface $indexAction, ActionFactory $actionFactory, ActionInterface $action1, ActionInterface $action2) { $action1->implement('Pim\\Bundle\\CustomEntityBundle\\Action\\GridActionInterface'); $action2->implement('Pim\\Bundle\\CustomEntityBundle\\Action\\GridActionInterface'); $actionFactory->getAction('entity', 'action1')->willReturn($action1); $actionFactory->getAction('entity', 'action2')->willReturn($action2); $action1->getGridActionOptions()->willReturn(['action1_key1' => 'action1_value1']); $datagridConfig->getName()->willReturn('entity'); $indexAction->getMassActions()->willReturn(['action1', 'action2']); $indexAction->getRowActions()->willReturn([]); $indexAction->getOptions()->willReturn([]); $datagridConfig->offsetGetByPath('[extends]')->willReturn('custom_entity'); $datagridConfig->offsetGetByPath('[properties]')->willReturn([]); $datagridConfig->offsetGetByPath('[actions]')->willReturn([]); $datagridConfig->offsetGetByPath('[source]')->willReturn([]); $datagridConfig->offsetGetByPath('[mass_actions]')->willReturn(['action2' => []]); $datagridConfig->offsetSetByPath("[source]", ["entity" => "entity_class", "type" => "pim_custom_entity"])->shouldBeCalled(); $datagridConfig->offsetSetByPath("[actions]", [])->shouldBeCalled(); $datagridConfig->offsetSetByPath("[properties]", ['id' => []])->shouldBeCalled(); $datagridConfig->offsetSetByPath("[mass_actions]", ["action2" => [], "action1" => ["action1_key1" => "action1_value1"]])->shouldBeCalled(); $this->buildBefore($event); }