/**
  * Validate configs nad fill default values
  *
  * @param DatagridConfiguration $config
  */
 public function processConfigs(DatagridConfiguration $config)
 {
     $configItems = $config->offsetGetOr(Configuration::BASE_CONFIG_KEY, []);
     $configuration = new Configuration(Configuration::BASE_CONFIG_KEY);
     $normalizedConfigItems = $this->validateConfiguration($configuration, [Configuration::BASE_CONFIG_KEY => $configItems]);
     $isGranted = $this->securityFacade->isGranted('EDIT', 'entity:' . $configItems['entity_name']);
     //according to ACL disable inline editing for the whole grid
     if (!$isGranted) {
         $normalizedConfigItems[Configuration::CONFIG_KEY_ENABLE] = false;
     }
     // replace config values by normalized, extra keys passed directly
     $resultConfigItems = array_replace_recursive($configItems, $normalizedConfigItems);
     if (is_null($resultConfigItems['save_api_accessor']['default_route_parameters']['className'])) {
         $resultConfigItems['save_api_accessor']['default_route_parameters']['className'] = $this->entityClassNameHelper->getUrlSafeClassName($configItems['entity_name']);
     }
     $config->offsetSet(Configuration::BASE_CONFIG_KEY, $resultConfigItems);
     //add inline editing where it is possible, do not use ACL, because additional parameters for columns needed
     $columns = $config->offsetGetOr(FormatterConfiguration::COLUMNS_KEY, []);
     $blackList = $configuration->getBlackList();
     foreach ($columns as $columnName => &$column) {
         if (!in_array($columnName, $blackList)) {
             $newColumn = $this->guesser->getColumnOptions($columnName, $configItems['entity_name'], $column);
             //frontend type key must not be replaced with default value
             $typeKey = PropertyInterface::FRONTEND_TYPE_KEY;
             if (!empty($newColumn[$typeKey])) {
                 $column[$typeKey] = $newColumn[$typeKey];
             }
             $column = array_replace_recursive($newColumn, $column);
         }
     }
     $config->offsetSet(FormatterConfiguration::COLUMNS_KEY, $columns);
 }
 /**
  * @param array $configValues
  * @param string $entityName
  * @dataProvider setParametersDataProvider
  */
 public function testProcessConfigs(array $configValues, $entityName)
 {
     $config = DatagridConfiguration::create($configValues);
     $callback = $this->getProcessConfigsCallBack();
     $this->guesser->expects($this->any())->method('getColumnOptions')->will($this->returnCallback($callback));
     $this->entityClassNameHelper->expects($this->any())->method('getUrlSafeClassName')->willReturn('Oro_Bundle_EntityBundle_Tests_Unit_Fixtures_Stub_SomeEntity');
     $this->extension->processConfigs($config);
     $expectedValues = $this->getProcessConfigsExpectedValues($entityName);
     $expectedResult = DatagridConfiguration::create($expectedValues);
     $key = Configuration::BASE_CONFIG_KEY;
     $this->assertEquals($config->offsetGet($key), $expectedResult->offsetGet($key));
     $key = FormatterConfiguration::COLUMNS_KEY;
     $this->assertEquals($config->offsetGet($key), $expectedResult->offsetGet($key));
 }
 public function testProcessConfigs()
 {
     $entityName = 'Oro\\Bundle\\EntityBundle\\Tests\\Unit\\Fixtures\\Stub\\SomeEntity';
     $configValues = [Configuration::BASE_CONFIG_KEY => ['enable' => true, 'entity_name' => $entityName], FormatterConfiguration::COLUMNS_KEY => ['testText' => ['label' => 'test_text'], 'testSelect' => ['label' => 'test_select', PropertyInterface::FRONTEND_TYPE_KEY => 'string'], 'testAnotherText' => ['label' => 'test_config_overwrite', 'inline_editing' => ['enable' => false]], 'id' => ['label' => 'test_black_list'], 'updatedAt' => ['label' => 'test_black_list'], 'createdAt' => ['label' => 'test_black_list']]];
     $config = DatagridConfiguration::create($configValues);
     $callback = $this->getProcessConfigsCallBack();
     $this->guesser->expects($this->any())->method('getColumnOptions')->will($this->returnCallback($callback));
     $this->entityClassNameHelper->expects($this->any())->method('getUrlSafeClassName')->willReturn('Oro_Bundle_EntityBundle_Tests_Unit_Fixtures_Stub_SomeEntity');
     $this->extension->processConfigs($config);
     $expectedValues = $this->getProcessConfigsExpectedValues($entityName);
     $expectedResult = DatagridConfiguration::create($expectedValues);
     $key = Configuration::BASE_CONFIG_KEY;
     $this->assertEquals($config->offsetGet($key), $expectedResult->offsetGet($key));
     $key = FormatterConfiguration::COLUMNS_KEY;
     $this->assertEquals($config->offsetGet($key), $expectedResult->offsetGet($key));
 }