protected function normaliseRenderOptions() { return ArrayUtilities::combine(array(self::RENDER_OPTION_KEY_ERROR_WRAPPER_ELEMENT_NAME => 'div', self::RENDER_OPTION_KEY_ERROR_WRAPPER_ATTRIBUTES => array()), parent::normaliseRenderOptions()); }
/** * @inheritdoc */ protected function normaliseRenderOptions() { return ArrayUtilities::combine(parent::normaliseRenderOptions(), array(self::RENDER_OPTION_KEY_ATTRIBUTES => array('type' => $this->getField()->getType() ?: 'text'))); }
/** * @inheritdoc */ protected function normaliseRenderOptions() { return ArrayUtilities::combine(array(self::RENDER_OPTION_KEY_CAPTCHA_IMAGE_ATTRIBUTES => array('class' => 'sitegear-captcha-image')), ArrayUtilities::combine(parent::normaliseRenderOptions(), array(self::RENDER_OPTION_KEY_ATTRIBUTES => array('type' => $this->getField()->getType() ?: 'text')))); }
/** * @inheritdoc */ protected function normaliseRenderOptions() { return ArrayUtilities::combine(array(self::RENDER_OPTION_KEY_OUTER_WRAPPER_ELEMENT_NAME => 'div', self::RENDER_OPTION_KEY_OUTER_WRAPPER_ATTRIBUTES => array('id' => sprintf('%s-container', $this->getField()->getName()), 'class' => sprintf('multiple-input-container %s-container', $this->getField()->getType())), self::RENDER_OPTION_KEY_INNER_WRAPPER_ELEMENT_NAME => 'div', self::RENDER_OPTION_KEY_INNER_WRAPPER_ATTRIBUTES => array(), self::RENDER_OPTION_KEY_INNER_WRAPPER_ID_PREFIX => 'value', self::RENDER_OPTION_KEY_LABELS_FIRST => false), parent::normaliseRenderOptions()); }
/** * @inheritdoc */ protected function normaliseRenderOptions() { return ArrayUtilities::combine(array(self::RENDER_OPTION_KEY_ATTRIBUTES => array('id' => $this->getField()->getName())), ArrayUtilities::combine(parent::normaliseRenderOptions(), array(self::RENDER_OPTION_KEY_ATTRIBUTES => array('name' => $this->getFieldNameAttribute())))); }
public function testCombineDeepNesting() { $array1 = array(); $array2 = array(); $nest1 = $array1; $nest2 = $array2; foreach (range(0, 99) as $i) { $nest1['simple-' . $i] = 'array1-' . $i; $nest2['simple-' . $i] = 'array2-' . $i; $nest1 = $nest1['nested-' . $i] = array(); $nest2 = $nest2['nested-' . $i] = array(); } $this->assertEquals($nest2, ArrayUtilities::combine($array1, $array2)); }
/** * @inheritdoc */ protected function normaliseRenderOptions() { return ArrayUtilities::combine(array(self::RENDER_OPTION_KEY_MARKER_SEPARATOR => ''), parent::normaliseRenderOptions()); }
/** * This method should be overridden by subclasses wishing to extend the normalising behaviour (e.g. ensure the * existence of additional keys, etc). Overriding implementations should be sure to call this implementation to * provide a baseline. * * @return array */ protected function normaliseRenderOptions() { $class = new \ReflectionClass($this); return ArrayUtilities::combine(array(self::RENDER_OPTION_KEY_ELEMENT_NAME => 'div', self::RENDER_OPTION_KEY_ATTRIBUTES => array()), $this->getFactory()->getRenderOptionDefaults($class->getName())); }
/** * Loa the data from the given location, according to any available loaders. * * If the given argument is a filename, also load the relevant environment-specific override file. * * @param array|string|\ArrayObject|\Sitegear\Config\Configuration $config Configuration data, filename or * configuration object. * * @return array Loaded data. * * @throws \InvalidArgumentException If the given argument is not a string or an array. */ public function load($config) { LoggerRegistry::debug('ConfigLoader::load({config})', array('config' => TypeUtilities::describe($config))); $result = $this->normalise($config); if (is_string($config) && !is_null($this->environmentInfo) && !is_null($this->environmentInfo->getEnvironment())) { $pathinfo = pathinfo($config); $dirname = array_key_exists('dirname', $pathinfo) ? strval($pathinfo['dirname']) : ''; $filename = array_key_exists('filename', $pathinfo) ? strval($pathinfo['filename']) : ''; $extension = array_key_exists('extension', $pathinfo) ? strval($pathinfo['extension']) : ''; $envFilename = sprintf('%s/%s.%s.%s', $dirname, $filename, $this->environmentInfo->getEnvironment(), $extension); $envConfig = $this->loadFile($envFilename); $result = ArrayUtilities::combine($result, $envConfig); } return $result; }
/** * @inheritdoc */ protected function normaliseRenderOptions() { return ArrayUtilities::combine(parent::normaliseRenderOptions(), array(self::RENDER_OPTION_KEY_ATTRIBUTES => array('rows' => $this->getField()->getRows(), 'cols' => $this->getField()->getCols()))); }
/** * @inheritdoc */ protected function normaliseRenderOptions() { return ArrayUtilities::combine(parent::normaliseRenderOptions(), array(self::RENDER_OPTION_KEY_ELEMENT_NAME => 'fieldset', self::RENDER_OPTION_KEY_ATTRIBUTES => array('id' => sprintf('sitegear-fieldset-%s', NameUtilities::convertToDashedLower($this->getFieldset()->getHeading()))))); }
/** * Load the given configuration file, and its relative environment-specific file (see class docs), and merge the * contents with the existing configuration. * * @param string|array $config The base filename to load, or an array of values to merge in directly. * @param null|string|array $rootKey The root key to merge the values to, will be created if it does not exist. If * omitted, the values will be merged to the root of the existing config. * @param boolean $preferExisting Whether to prefer values from the passed-in config over the existing values (the * default) or to prefer existing values over passed-in values (if this argument is true). * * @return self * * @throws \InvalidArgumentException */ public function merge($config, $rootKey = null, $preferExisting = false) { LoggerRegistry::debug('Configuration::merge({config}, {rootKey}, {preferExisting})', array('config' => TypeUtilities::describe($config), 'rootKey' => TypeUtilities::describe($rootKey), 'preferExisting' => TypeUtilities::describe($preferExisting))); // Load using the container's ConfigLoader. $data = $this->loader->load($config); // Push the data down the hierarchy to the specified root key. $rootKey = $this->normaliseKey($rootKey); while (!empty($rootKey)) { $k = array_pop($rootKey); $data = array($k => $data); } // Combine the arrays depending on the $preferExisting flag. $this->data = $preferExisting ? ArrayUtilities::combine($data, $this->data) : ArrayUtilities::combine($this->data, $data); return $this; }
/** * @inheritdoc */ protected function normaliseRenderOptions() { return ArrayUtilities::combine(parent::normaliseRenderOptions(), array(self::RENDER_OPTION_KEY_ELEMENT_NAME => 'form', self::RENDER_OPTION_KEY_ATTRIBUTES => array('action' => $this->form->getSubmitUrl(), 'method' => $this->form->getMethod()))); }