_initConfig() protected static method

A stub method called by _config() which allows Adaptable subclasses to automatically assign or auto-generate additional configuration data, once a configuration is first accessed. This allows configuration data to be lazy-loaded from adapters or other data sources.
protected static _initConfig ( string $name, array $config ) : array
$name string The name of the configuration which is being accessed. This is the key name containing the specific set of configuration passed into `config()`.
$config array Contains the configuration assigned to `$name`. If this configuration is segregated by environment, then this will contain the configuration for the current environment.
return array Returns the final array of settings for the given named configuration.
Esempio n. 1
0
 /**
  * Called when an adapter configuration is first accessed, this method sets the default
  * configuration for session handling. While each configuration can use its own session class
  * and options, this method initializes them to the default dependencies written into the class.
  * For the session key name, the default value is set to the name of the configuration.
  *
  * @param string $name The name of the adapter configuration being accessed.
  * @param array $config The user-specified configuration.
  * @return array Returns an array that merges the user-specified configuration with the
  *         generated default values.
  */
 protected static function _initConfig($name, $config)
 {
     $defaults = array('session' => array('key' => $name, 'class' => static::$_classes['session'], 'options' => array()));
     $config = parent::_initConfig($name, $config) + $defaults;
     $config['session'] += $defaults['session'];
     return $config;
 }
Esempio n. 2
0
 /**
  * Initializes configuration with default settings
  *
  * @param string $name The name of the configuration which is being accessed. This is the key
  *               name containing the specific set of configuration passed into `config()`.
  * @param array $config Contains the configuration assigned to `$name`. If this configuration is
  *              segregated by environment, then this will contain the configuration for the
  *              current environment.
  * @return array Returns the final array of settings for the given named configuration.
  */
 protected static function _initConfig($name, $config)
 {
     $defaults = ['filters' => [], 'servers' => []];
     $config = parent::_initConfig($name, $config) + $defaults;
     foreach (['filters', 'servers'] as $arrayVar) {
         if (!empty($config[$arrayVar]) && !is_array($config[$arrayVar])) {
             $config[$arrayVar] = (array) $config[$arrayVar];
         } elseif (empty($config[$arrayVar])) {
             $config[$arrayVar] = [];
         }
     }
     if (empty($config['adapter'])) {
         $config['adapter'] = 'Job';
     }
     return $config;
 }
Esempio n. 3
0
	/**
	 * Called when an adapter configuration is first accessed, this method sets the default
	 * configuration for session handling. While each configuration can use its own session class
	 * and options, this method initializes them to the default dependencies written into the class.
	 * For the session key name, the default value is set to the name of the configuration.
	 *
	 * @param string $name The name of the adapter configuration being accessed.
	 * @param array $config The user-specified configuration.
	 * @return array Returns an array that merges the user-specified configuration with the
	 *         generated default values.
	 */
	protected static function _initConfig($name, $config) {
		$defaults = array();
		$config = parent::_initConfig($name, $config) + $defaults;
		return $config;
	}
Esempio n. 4
0
 /**
  * Called when an adapter configuration is first accessed, this method sets the default
  * configuration for session handling. While each configuration can use its own session class
  * and options, this method initializes them to the default dependencies written into the class.
  * For the session key name, the default value is set to the name of the configuration.
  *
  * @param string $name The name of the adapter configuration being accessed.
  * @param array $config The user-specified configuration.
  * @return array Returns an array that merges the user-specified configuration with the
  *         generated default values.
  */
 protected static function _initConfig($name, $config)
 {
     $defaults = array('adapter' => 'Model', 'events' => true, 'groups' => array());
     $config = parent::_initConfig($name, $config) + $defaults;
     return $config;
 }
Esempio n. 5
0
 /**
  * This method is called automatically to initialize the default configuration of a log adapter,
  * such that the adapter defaults to accepting log messages of any priority (i.e. the
  * `'priority'` key is set to `true`).
  *
  * @param string $name The name of the logger configuration.
  * @param array $config The logger configuration as specified in application code.
  * @return array Returns an array of configuration data, merged with default values.
  */
 protected static function _initConfig($name, $config)
 {
     $defaults = array('priority' => true);
     return parent::_initConfig($name, $config) + $defaults;
 }