__construct() публичный Метод

Constructor. Initializes class configuration ($_config), and assigns object properties using the _init() method, unless otherwise specified by configuration. See below for details.
См. также: lithium\core\Object::$_config
См. также: lithium\core\Object::_init()
public __construct ( array $config = [] ) : void
$config array The configuration options which will be assigned to the `$_config` property. This method accepts one configuration option: - `'init'` _boolean_: Controls constructor behavior for calling the `_init()` method. If `false`, the method is not called, otherwise it is. Defaults to `true`.
Результат void
Пример #1
0
 /**
  * Constructor.
  *
  * @param array $config Configuration array. You can override the default algorithm.
  */
 public function __construct(array $config = [])
 {
     if (!isset($config['secret'])) {
         throw new ConfigException('Jwt strategy requires a secret key.');
     }
     parent::__construct($config + $this->_defaults);
 }
Пример #2
0
 /**
  * Constructor.
  *
  * @param array $config Optional configuration parameters.
  * @return void
  */
 public function __construct(array $config = [])
 {
     if (!isset($config['header'])) {
         throw new ConfigException('Token adapter requires a header.');
     }
     parent::__construct($config + $this->_defaults);
 }
Пример #3
0
 /**
  * Initializes a new `Service` instance with the default HTTP request settings and
  * transport- and format-handling classes.
  *
  * @param array $config
  * @return void
  */
 public function __construct($config = array())
 {
     $defaults = array('autoConnect' => true, 'persistent' => false, 'protocol' => 'http', 'host' => 'localhost', 'version' => '1.1', 'auth' => 'Basic', 'login' => 'root', 'password' => '', 'port' => 80, 'timeout' => 1, 'encoding' => 'UTF-8');
     $config = (array) $config + $defaults;
     $config['auth'] = array('method' => $config['auth'], 'username' => $config['login'], 'password' => $config['password']);
     parent::__construct($config);
 }
Пример #4
0
 /**
  * Class constructor.
  *
  * Takes care of setting appropriate configurations for this object.
  *
  * @param array $config Optional configuration parameters.
  */
 public function __construct(array $config = array())
 {
     if (empty($config['name'])) {
         $config['name'] = basename(LITHIUM_APP_PATH) . 'cookie';
     }
     parent::__construct($config + $this->_defaults);
 }
Пример #5
0
	/**
	 * Class constructor.
	 *
	 * @param array $config
	 */
	public function __construct(array $config = array()) {
		$defaults = array(
			'prefix' => '',
			'expiry' => '+1 hour'
		);
		parent::__construct($config + $defaults);
	}
Пример #6
0
 /**
  * Constructor.
  *
  * @see lithium\util\String::insert()
  * @param array $config Settings used to configure the adapter. Available options:
  *        - `'path'` _string_: The directory to write log files to. Defaults to
  *          `<app>/resources/tmp/logs`.
  *        - `'timestamp'` _string_: The `date()`-compatible timestamp format. Defaults to
  *          `'Y-m-d H:i:s'`.
  *        - `'file'` _\Closure_: A closure which accepts two parameters: an array
  *          containing the current log message details, and an array containing the `File`
  *          adapter's current configuration. It must then return a file name to write the
  *          log message to. The default will produce a log file name corresponding to the
  *          priority of the log message, i.e. `"debug.log"` or `"alert.log"`.
  *        - `'format'` _string_: A `String::insert()`-compatible string that specifies how
  *          the log message should be formatted. The default format is
  *          `"{:timestamp} {:message}\n"`.
  * @return void
  */
 public function __construct(array $config = array())
 {
     $defaults = array('path' => Libraries::get(true, 'resources') . '/tmp/logs', 'timestamp' => 'Y-m-d H:i:s', 'file' => function ($data, $config) {
         return "{$data['priority']}.log";
     }, 'format' => "{:timestamp} {:message}\n");
     parent::__construct($config + $defaults);
 }
Пример #7
0
 /**
  * Constructor.
  *
  * Takes care of setting appropriate configurations for this object.
  *
  * @param array $config Optional configuration parameters.
  * @return void
  */
 public function __construct(array $config = array())
 {
     if (empty($config['name'])) {
         $config['name'] = basename(Libraries::get(true, 'path')) . 'cookie';
     }
     parent::__construct($config + $this->_defaults);
 }
Пример #8
0
	/**
	 * Class constructor.
	 *
	 * @param array $config
	 */
	public function __construct(array $config = array()) {
		$defaults = array(
			'config' => null,
			'expiry' => '+999 days',
			'key' => 'log_{:type}_{:timestamp}'
		);
		parent::__construct($config + $defaults);
	}
Пример #9
0
	/**
	 * Object constructor
	 *
	 * Instantiates the `Redis` object and connects it to the configured server.
	 *
	 * @todo Implement configurable & optional authentication
	 * @see lithium\storage\Cache::config()
	 * @see lithium\storage\cache\adapter\Redis::_ttl()
	 * @param array $config Configuration parameters for this cache adapter.
	 *        These settings are indexed by name and queryable through `Cache::config('name')`. The
	 *        available settings for this adapter are as follows:
	 *        - `'host'` _string_: A string in the form of `'host:port'` indicating the Redis server
	 *          to connect to. Defaults to `'127.0.0.1:6379'`.
	 *        - `'expiry'` _mixed_: Default expiration for cache values written through this
	 *          adapter. Defaults to `'+1 hour'`. For acceptable values, see the `$expiry` parameter
	 *          of `Redis::_ttl()`.
	 *        - `'persistent'` _boolean_: Indicates whether the adapter should use a persistent
	 *          connection when attempting to connect to the Redis server. If `true`, it will
	 *          attempt to reuse an existing connection when connecting, and the connection will
	 *          not close when the request is terminated. Defaults to `false`.
	 */
	public function __construct(array $config = array()) {
		$defaults = array(
			'host' => '127.0.0.1:6379',
			'expiry' => '+1 hour',
			'persistent' => false
		);
		parent::__construct($config + $defaults);
	}
Пример #10
0
 /**
  * Constructor
  *
  * @param array $options Options
  */
 public function __construct(array $options)
 {
     parent::__construct($options);
     $this->client = new GearmanClient();
     foreach ($this->_config['servers'] as $server) {
         $this->client->addServer($server);
     }
 }
Пример #11
0
 public function __construct(array $config = array())
 {
     if (isset($config['autoConfig'])) {
         $this->_autoConfig = (array) $config['autoConfig'];
         unset($config['autoConfig']);
     }
     parent::__construct($config);
 }
Пример #12
0
 /**
  * Adds config values to the public properties when a new object is created.
  *
  * @param array $config Configuration options : default value
  * - `scheme`: tcp
  * - `host`: localhost
  * - `port`: null
  * - `username`: null
  * - `password`: null
  * - `path`: null
  * - `body`: null
  */
 public function __construct(array $config = array())
 {
     $defaults = array('scheme' => 'tcp', 'host' => 'localhost', 'port' => null, 'username' => null, 'password' => null, 'path' => null, 'body' => null);
     $config += $defaults;
     foreach (array_intersect_key(array_filter($config), $defaults) as $key => $value) {
         $this->{$key} = $value;
     }
     parent::__construct($config);
 }
Пример #13
0
	/**
	 * Sets default adapter configuration.
	 *
	 * @param array $config Adapter configuration, which includes the following default options:
	 *              - `'rules'` _array_: An array of rules to be added to the default rules
	 *                initialized by the adapter. See the `'rules'` option of the `check()` method
	 *                for more information on the acceptable format of these values.
	 *              - `'default'` _array_: The default list of rules to use when performing access
	 *                checks.
	 *              - `'allowAny'` _boolean_: If set to `true`, access checks will return successful
	 *                if _any_ access rule passes. Otherwise, all are required to pass in order for
	 *                the check to succeed. Defaults to `false`.
	 */
	public function __construct(array $config = array()) {
		$defaults = array(
			'rules' => array(),
			'default' => array(),
			'allowAny' => false,
			'user' => function() {}
		);
		parent::__construct($config + $defaults);
	}
Пример #14
0
 public function __construct(array $config = array())
 {
     $defaults = array('method' => null, 'data' => null, 'options' => array());
     $this->_requestTypes = array('use' => function ($tube, $options) {
         return sprintf('use %s', $tube);
     }, 'put' => function ($data, $options) {
         extract($options, EXTR_OVERWRITE);
         $cmd = sprintf('put %d %d %d %d', $pri, $delay, $ttr, strlen($data));
         return join("\r\n", array($cmd, $data));
     }, 'reserve' => function ($data, array $options = array()) {
         return 'reserve';
     }, 'reserve-with-timeout' => function ($data, array $options = array()) {
         extract($options, EXTR_OVERWRITE);
         return sprintf('reserve-with-timeout %d', $timeout);
     }, 'release' => function ($id, array $options = array()) {
         extract($options, EXTR_OVERWRITE);
         return sprintf('release %d %d %d', $id, $pri, $delay);
     }, 'delete' => function ($id, array $options = array()) {
         return sprintf('delete %d', $id);
     }, 'bury' => function ($id, array $options = array()) {
         return sprintf('delete %d %d', $id, $pri);
     }, 'touch' => function ($id, array $options = array()) {
         return sprintf('touch %d', $id);
     }, 'watch' => function ($tube, array $options = array()) {
         return sprintf('watch %s', $tube);
     }, 'ignore' => function ($tube, array $options = array()) {
         return sprintf('ignore %s', $tube);
     }, 'peek' => function ($id, array $options = array()) {
         return sprintf('peek %d', $id);
     }, 'peek-ready' => function ($data, array $options = array()) {
         return sprintf('peek-ready');
     }, 'peek-delayed' => function ($data, array $options = array()) {
         return sprintf('peek-delayed');
     }, 'peek-buried' => function ($data, array $options = array()) {
         return sprintf('peek-buried');
     }, 'kick' => function ($bound, array $options = array()) {
         return sprintf('kick %d', $bound);
     }, 'kick-job' => function ($id, array $options = array()) {
         return sprintf('kick-job %d', $id);
     }, 'stats-job' => function ($id, array $options = array()) {
         return sprintf('stats-job %d', $id);
     }, 'stats-tube' => function ($tube, array $options = array()) {
         return sprintf('stats-tube %s', $tube);
     }, 'stats' => function ($data, array $options = array()) {
         return 'stats';
     }, 'list-tubes' => function ($data, array $options = array()) {
         return 'list-tubes';
     }, 'list-tube-used' => function ($data, array $options = array()) {
         return 'list-tube-used';
     }, 'list-tubes-watched' => function ($data, array $options = array()) {
         return 'list-tubes-watched';
     }, 'pause-tube' => function ($data, array $options = array()) {
         return 'pause-tube';
     });
     return parent::__construct($config + $defaults);
 }
Пример #15
0
 /**
  * Object constructor.
  * Instantiates the Memcached object, adds appropriate servers to the pool,
  * and configures any optional settings passed.
  *
  * @see lithium\storage\Cache::config()
  * @param array $config Configuration parameters for this cache adapter.
  *        These settings are indexed by name and queryable
  *        through `Cache::config('name')`.
  * @return void
  */
 public function __construct(array $config = array())
 {
     $defaults = array('prefix' => '', 'expiry' => '+1 hour', 'servers' => array(array('127.0.0.1', 11211, 100)));
     if (is_null(static::$connection)) {
         static::$connection = new \Memcached();
     }
     $configuration = Set::merge($defaults, $config);
     parent::__construct($configuration);
     static::$connection->addServers($this->_config['servers']);
 }
Пример #16
0
 /**
  * Growl logger constructor. Accepts an array of settings which are merged with the default
  * settings and used to create the connection and handle notifications.
  *
  * @see lithium\analysis\Logger::write()
  * @param array $config The settings to configure the logger. Available settings are as follows:
  *              - `'name`' _string_: The name of the application as it should appear in Growl's
  *                system settings. Defaults to the directory name containing your application.
  *              - `'host'` _string_: The Growl host with which to communicate, usually your
  *                local machine. Use this setting to send notifications to another machine on
  *                the network. Defaults to `'127.0.0.1'`.
  *              - `'port'` _integer_: Port of the host machine. Defaults to the standard Growl
  *                port, `9887`.
  *              - `'password'` _string_: Only required if the host machine requires a password.
  *                If notification or registration fails, check this against the host machine's
  *                Growl settings.
  *              - '`protocol'` _string_: Protocol to use when opening socket communication to
  *                Growl. Defaults to `'udp'`.
  *              - `'title'` _string_: The default title to display when showing Growl messages.
  *                The default value is the same as `'name'`, but can be changed on a per-message
  *                basis by specifying a `'title'` key in the `$options` parameter of
  *                `Logger::write()`.
  *              - `'notification'` _array_: A list of message types you wish to register with
  *                Growl to be able to send. Defaults to `array('Errors', 'Messages')`.
  * @return void
  */
 public function __construct(array $config = array())
 {
     $name = basename(LITHIUM_APP_PATH);
     $defaults = array('name' => $name, 'host' => '127.0.0.1', 'port' => 9887, 'password' => null, 'protocol' => 'udp', 'title' => Inflector::humanize($name), 'notifications' => array('Errors', 'Messages'), 'connection' => function ($host, $port) {
         if ($conn = fsockopen($host, $port, $message, $code)) {
             return $conn;
         }
         throw new NetworkException("Growl connection failed: ({$code}) {$message}");
     });
     parent::__construct($config + $defaults);
 }
Пример #17
0
 /**
  * Object constructor
  *
  * Instantiates the Redis object and connects it to the configured server.
  *
  * @param array $config Configuration parameters for this cache adapter.
  *        These settings are indexed by name and queryable through `Cache::config('name')`.
  *
  * @return void
  * @see lithium\storage\Cache::config()
  * @todo Implement configurable & optional authentication
  */
 public function __construct($config = array())
 {
     $defaults = array('prefix' => '', 'server' => '127.0.0.1:6379');
     if (is_null(static::$_Redis)) {
         static::$_Redis = new \Redis();
     }
     $config += $defaults;
     parent::__construct($config);
     list($IP, $port) = explode(':', $this->_config['server']);
     static::$_Redis->connect($IP, $port);
 }
Пример #18
0
 /**
  * Construct Request object
  *
  * @param array $config
  *              - request object lithium\console\Request
  *              - output stream
  *              _ error stream
  */
 public function __construct($config = array())
 {
     $defaults = array('output' => null, 'error' => null);
     $config += $defaults;
     $this->output = $config['output'];
     if (!is_resource($this->output)) {
         $this->output = fopen('php://stdout', 'r');
     }
     $this->error = $config['error'];
     if (!is_resource($this->error)) {
         $this->error = fopen('php://stderr', 'r');
     }
     parent::__construct($config);
 }
Пример #19
0
 /**
  * Constructor.
  *
  * @param array $config Configuration array. You can override the default cipher and mode.
  */
 public function __construct(array $config = array())
 {
     if (!static::enabled()) {
         throw new ConfigException("The Mcrypt extension is not installed or enabled.");
     }
     if (!isset($config['secret'])) {
         throw new ConfigException("Encrypt strategy requires a secret key.");
     }
     parent::__construct($config + $this->_defaults);
     $cipher = $this->_config['cipher'];
     $mode = $this->_config['mode'];
     static::$_resource = mcrypt_module_open($cipher, '', $mode, '');
     $this->_config['vector'] = static::_vector();
 }
Пример #20
0
	/**
	 * Initializes a new `Service` instance with the default HTTP request settings and
	 * transport- and format-handling classes.
	 * @param array $config
	 */
	public function __construct(array $config = array()) {
		$defaults = array(
			'persistent' => false,
			'scheme'     => 'http',
			'host'       => 'localhost',
			'port'       => null,
			'timeout'    => 30,
			'auth'       => null,
			'username'   => null,
			'password'   => null,
			'encoding'   => 'UTF-8',
			'socket'     => 'Context'
		);
		parent::__construct($config + $defaults);
	}
Пример #21
0
	/**
	 * Constructor.
	 *
	 * @param array $config Configuration array. You can override the default cipher and mode.
	 */
	public function __construct(array $config = array()) {
		if (!static::enabled()) {
			throw new ConfigException("The Mcrypt extension is not installed or enabled.");
		}
		if (!isset($config['secret'])) {
			throw new ConfigException("Encrypt strategy requires a secret key.");
		}
		$defaults = array(
			'cipher' => MCRYPT_RIJNDAEL_256,
			'mode' => MCRYPT_MODE_CBC
		);
		parent::__construct($config + $defaults);

		$cipher = $this->_config['cipher'];
		$mode = $this->_config['mode'];
		$this->_config['vector'] = static::_vector($cipher, $mode);
	}
Пример #22
0
 /**
  * Adds config values to the public properties when a new object is created.
  *
  * @param array $config Options.
  */
 public function __construct(array $config = array())
 {
     $grammar = array();
     $grammar['NO-WS-CTL'] = '[\\x01-\\x08\\x0B\\x0C\\x0E-\\x19\\x7F]';
     $grammar['text'] = '[\\x00-\\x08\\x0B\\x0C\\x0E-\\x7F]';
     $grammar['quoted-pair'] = "(?:\\\\{$grammar['text']})";
     $grammar['qtext'] = "(?:{$grammar['NO-WS-CTL']}|" . '[\\x21\\x23-\\x5B\\x5D-\\x7E])';
     $grammar['atext'] = '[a-zA-Z0-9!#\\$%&\'\\*\\+\\-\\/=\\?\\^_`\\{\\}\\|~]';
     $grammar['dot-atom-text'] = "(?:{$grammar['atext']}+" . "(\\.{$grammar['atext']}+)*)";
     $grammar['no-fold-quote'] = "(?:\"(?:{$grammar['qtext']}|" . "{$grammar['quoted-pair']})*\")";
     $grammar['dtext'] = "(?:{$grammar['NO-WS-CTL']}|" . '[\\x21-\\x5A\\x5E-\\x7E])';
     $grammar['no-fold-literal'] = "(?:\\[(?:{$grammar['dtext']}|" . "{$grammar['quoted-pair']})*\\])";
     $grammar['id-left'] = "(?:{$grammar['dot-atom-text']}|" . "{$grammar['no-fold-quote']})";
     $grammar['id-right'] = "(?:{$grammar['dot-atom-text']}|" . "{$grammar['no-fold-literal']})";
     $provided = isset($config['grammar']) ? $config['grammar'] : null;
     $grammar = array_merge_recursive($grammar, (array) $provided);
     parent::__construct(compact('grammar') + $config);
 }
Пример #23
0
 public function __construct($config)
 {
     parent::__construct($config);
     // Backwards section/element compatibility
     if (isset($config['section']) && isset($config['element'])) {
         // Section and element
         $this->_views[$config['section']] = $config['element'];
     } elseif (isset($config['section']) && count($this->_views) == 1) {
         // Section and single view
         $this->_views[$config['section']] = array_pop($this->_views);
     } elseif (isset($config['element']) && count($this->_views) == 1) {
         // Single view and element
         $keys = array_keys($this->_views);
         $this->_views[$keys[0]] = $config['element'];
     }
     // Name
     $this->name($config['adapter']);
 }
Пример #24
0
 /**
  * Setup default configuration options.
  *
  * @param array $config
  *        - `method`: default: `digest` options: `basic|digest`
  *        - `realm`: default: `Protected by Lithium`
  *        - `users`: the users to permit. key => value pair of username => password
  */
 public function __construct(array $config = array())
 {
     $defaults = array('method' => 'digest', 'realm' => basename(LITHIUM_APP_PATH), 'users' => array());
     parent::__construct($config + $defaults);
 }
Пример #25
0
 /**
  * Class constructor.
  *
  * Takes care of setting appropriate configurations for
  * this object.
  *
  * @param array $config
  * @return void
  */
 public function __construct($config = array())
 {
     parent::__construct((array) $config + $this->_defaults);
 }
Пример #26
0
 public function __construct(array $config = array())
 {
     $defaults = array('request' => null, 'response' => array(), 'render' => array(), 'classes' => array());
     parent::__construct($config + $defaults);
 }
Пример #27
0
 public function __construct(array $config = array())
 {
     $defaults = array('params' => array(), 'template' => '/', 'pattern' => '', 'match' => array(), 'meta' => array(), 'defaults' => array(), 'keys' => array(), 'persist' => array(), 'handler' => null, 'continue' => false);
     parent::__construct($config + $defaults);
 }
Пример #28
0
 /**
  * Sets up the adapter with the configuration assigned by the `Session` class.
  *
  * @param array $config Available configuration options for this adapter:
  *              - `'config'` _string_: The name of the model that this adapter should use.
  */
 public function __construct(array $config = array())
 {
     $defaults = array('model' => null, 'expiry' => '+2 hours');
     parent::__construct($config + $defaults);
 }
Пример #29
0
	/**
	 * Constructor.
	 *
	 * @param array $config Configuration parameters.
	 *        The available options are:
	 *          - `'loader'` _mixed_: For locating/reading view, layout and element
	 *            templates. Defaults to `File`.
	 *          - `'renderer'` _mixed_: Populates the view/layout with the data set from the
	 *            controller. Defaults to `'File'`.
	 *          - `'request'`: The request object to be made available in the view.
	 *            Defaults to `null`.
	 *          - `'vars'`: Defaults to `array()`.
	 */
	public function __construct(array $config = array()) {
		$defaults = array(
			'request' => null,
			'response' => null,
			'vars' => array(),
			'loader' => 'File',
			'renderer' => 'File',
			'steps' => array(),
			'processes' => array(),
			'outputFilters' => array()
		);
		parent::__construct($config + $defaults);
	}
Пример #30
0
 /**
  * Constructor.
  *
  * @param array $config Available options are:
  *        - `'autoConnect'` _boolean_: If `true`, a connection is made on
  *           initialization. Defaults to `true`.
  * @return void
  */
 public function __construct(array $config = array())
 {
     $defaults = array('autoConnect' => true);
     parent::__construct($config + $defaults);
 }