lithium\core\Adaptable::adapter PHP Method

adapter() public static method

Returns adapter class name for given $name configuration, using the $_adapter path defined in Adaptable subclasses.
public static adapter ( string | null $name = null ) : object
$name string | null Class name of adapter to load.
return object Adapter object.
    public static function adapter($name = null)
    {
        $config = static::_config($name);
        if ($config === null) {
            throw new ConfigException("Configuration `{$name}` has not been defined.");
        }
        if (isset($config['object'])) {
            return $config['object'];
        }
        $class = static::_class($config, static::$_adapters);
        $settings = static::$_configurations[$name];
        $settings[0]['object'] = static::_initAdapter($class, $config);
        static::$_configurations[$name] = $settings;
        return static::$_configurations[$name][0]['object'];
    }

Usage Example

Example #1
0
 /**
  * Override adapter retrival by not storing the object
  *
  * @see lithium\core\Adaptable::adapter
  */
 public static function adapter($name = null)
 {
     $object = parent::adapter($name);
     // Do not store the mail created
     unset(static::$_configurations[$name][0]['object']);
     return $object;
 }
All Usage Examples Of lithium\core\Adaptable::adapter