本文整理汇总了PHP中lithium\core\Object::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::__construct方法的具体用法?PHP Object::__construct怎么用?PHP Object::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lithium\core\Object
的用法示例。
在下文中一共展示了Object::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* Class constructor.
*
* @param array $config
*/
public function __construct(array $config = array()) {
$defaults = array(
'prefix' => '',
'expiry' => '+1 hour'
);
parent::__construct($config + $defaults);
}
示例6: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: __construct
/**
* 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: __construct
public function __construct(array $config = array())
{
if (isset($config['autoConfig'])) {
$this->_autoConfig = (array) $config['autoConfig'];
unset($config['autoConfig']);
}
parent::__construct($config);
}
示例12: __construct
/**
* 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: __construct
/**
* 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: __construct
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: __construct
/**
* 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']);
}