/** * @param OptionsResolverInterface $resolver * @param array $defaultConfig */ protected function setConfigsNormalizer(OptionsResolverInterface $resolver, array $defaultConfig) { $resolver->setNormalizers(['configs' => function (Options $options, $configs) use($defaultConfig) { $result = array_replace_recursive($defaultConfig, $configs); if ($autoCompleteAlias = $options->get('autocomplete_alias')) { $result['autocomplete_alias'] = $autoCompleteAlias; if (empty($result['properties'])) { $searchHandler = $this->searchRegistry->getSearchHandler($autoCompleteAlias); $result['properties'] = $searchHandler->getProperties(); } if (empty($result['route_name'])) { $result['route_name'] = 'oro_form_autocomplete_search'; } if (empty($result['extra_config'])) { $result['extra_config'] = 'autocomplete'; } } if (!array_key_exists('route_parameters', $result)) { $result['route_parameters'] = []; } if (empty($result['route_name'])) { throw new InvalidConfigurationException('Option "configs[route_name]" must be set.'); } return $result; }]); }
/** * @param OptionsResolver $resolver * @param array $defaultConfigs */ protected function setConfigsNormalizer(OptionsResolver $resolver, array $defaultConfigs) { $resolver->setNormalizer('autocomplete', function (Options $options, $configs) use($defaultConfigs) { $configs = array_replace_recursive($defaultConfigs, $configs); $configs['route_parameters']['per_page'] = $configs['per_page']; if (empty($configs['route_name']) && !empty($configs['alias'])) { $configs['route_name'] = 'oro_form_autocomplete_search'; $configs['route_parameters']['name'] = $configs['alias']; } if (empty($configs['properties']) && !empty($configs['alias'])) { $searchHandler = $this->searchRegistry->getSearchHandler($configs['alias']); $configs['properties'] = $searchHandler->getProperties(); } return $configs; }); }