public function addInitializerConfig($args) { if ($args) { $this->repository = util::array_get($args['repository'], $this->repository); $this->id = util::array_get($args['id'], $this->id); $this->value = util::array_get($args['value'], $this->value); } }
public function __construct($id, $args, AutoTablesGlobalConfiguration $globalConf) { $this->id = $id; $this->serviceId = util::array_get($args['service'], null); $this->repositoryId = util::array_get($args['repository'], null); $this->transScope = util::array_get($args['trans_scope'], $globalConf->getTransScope()); $this->dataTablesOptions = util::array_get($args['datatables_options'], $globalConf->getDataTablesOptions()); $this->views = util::array_get($args['views'], ''); $this->frontendFramework = $globalConf->getFrontendFramework(); $this->columns = util::array_get($args['columns'], array()); $this->updateRoute = util::array_get($args['updateRoute'], 'twentysteps_auto_tables_update'); $this->addRoute = util::array_get($args['addRoute'], 'twentysteps_auto_tables_add'); $this->deleteRoute = util::array_get($args['deleteRoute'], 'twentysteps_auto_tables_remove'); }
/** * {@inheritDoc} */ public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('services.yml'); $tables = util::array_get($config['tables']); if ($tables) { foreach ($tables as $tableDef) { $id = util::array_get($tableDef['id']); Ensure::isNotEmpty($id, "Missing [id] option in twentysteps_auto_tables table definition"); $json = util::array_get($tableDef['dataTablesOptions']) ?: '{}'; Ensure::isTrue($this->isValidJson($json), 'Encountered illegal JSON for twentysteps_auto_tables table with id [%s] in config: %s', $id, $json); $container->setParameter('twentysteps_auto_tables.config.' . $id, $tableDef); } } $defaultOpts = util::array_get($config['default_datatables_options']) ?: '{}'; Ensure::isTrue($this->isValidJson($defaultOpts), 'Encountered illegal JSON in config: %s', $defaultOpts); $container->setParameter('twentysteps_auto_tables.default_datatables_options', $defaultOpts); $container->setParameter('twentysteps_auto_tables.config', $config); }
/** * Tries to find the optional parameter $key in the $args array and returns the $defaultValue if * not found. */ protected function getParameter($args, $key, $defaultValue = NULL) { $value = util::array_get($args[$key]); return is_null($value) ? $defaultValue : $value; }
private function getColumnDescriptor($entity, $columnDescriptorId, AutoTablesConfiguration $config) { $columnDescriptor = util::array_get($this->columnDescriptorMap[$columnDescriptorId]); if (!$columnDescriptor) { $this->initDescriptors(new \ReflectionClass($entity), $config); $columnDescriptor = util::array_get($this->columnDescriptorMap[$columnDescriptorId]); Ensure::isNotNull($columnDescriptor, 'Failed to load column [%s] for entity of type [%s]', $columnDescriptorId, get_class($entity)); } return $columnDescriptor; }
public function addAutoTablesConfig(AutoTablesConfiguration $config, $selector) { $columnOverwrite = util::array_get($config->getColumns()[$selector]); if ($columnOverwrite) { $this->readOnly = util::array_get($columnOverwrite['readOnly'], $this->readOnly); $this->name = util::array_get($columnOverwrite['name'], $this->name); $this->type = util::array_get($columnOverwrite['type'], $this->type); $this->order = util::array_get($columnOverwrite['order'], $this->order); $this->ignore = util::array_get($columnOverwrite['ignore'], $this->ignore); $this->visible = util::array_get($columnOverwrite['visible'], $this->visible); $this->viewType = util::array_get($columnOverwrite['viewType'], $this->viewType); $this->values = util::array_get($columnOverwrite['values'], $this->values); $initializer = util::array_get($columnOverwrite['initializer'], null); if ($initializer) { if (!$this->initializer) { $this->initializer = new InitializerInfo(); } $this->initializer->addInitializerConfig($initializer); } } }
public function __construct($args) { $this->transScope = util::array_get($args['trans_scope'], 'messages'); $this->dataTablesOptions = util::array_get($args['datatables_options'], '{}'); $this->frontendFramework = FrontendFramework::fromString(util::array_get($args['frontend_framework'], FrontendFramework::toString(FrontendFramework::JQUERY_UI))); }
public function test_array_last_key() { $test = array('a' => array('a' => 'b', 'c' => 'd')); $this->assertEquals('c', util::array_last_key(util::array_get($test['a']))); }
private function mergeColumnsConfiguration(AutoTablesConfiguration $config, $args) { $newColArgs = util::array_get($args['columns'], array()); foreach ($newColArgs as $newColArg) { $selector = $newColArg['selector']; Ensure::isNotEmpty($selector, 'Missing selector in column configuration'); $colArg = util::array_get($config->getColumns()[$selector], null); if ($colArg) { // overwrite the settings $config->putColumn($selector, array_merge($colArg, $newColArg)); } else { // define a new entry $config->putColumn($selector, $newColArg); } } return $config; }