本文整理汇总了PHP中lithium\core\Object::_init方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::_init方法的具体用法?PHP Object::_init怎么用?PHP Object::_init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lithium\core\Object
的用法示例。
在下文中一共展示了Object::_init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _init
/**
* Initializes default rules to use.
*
* @return void
*/
protected function _init() {
parent::_init();
$this->_rules += array(
'allowAll' => function() {
return true;
},
'denyAll' => function() {
return false;
},
'allowAnyUser' => function($user) {
return $user ? true : false;
},
'allowIp' => function($user, $request, $options) {
$options += array('ip' => false);
if (is_string($options['ip']) && strpos($options['ip'], '/') === 0) {
return (boolean) preg_match($options['ip'], $request->env('REMOTE_ADDR'));
}
if (is_array($options['ip'])) {
return in_array($request->env('REMOTE_ADDR'), $options['ip']);
}
return $request->env('REMOTE_ADDR') == $options['ip'];
}
);
}
示例2: _init
protected function _init()
{
parent::_init();
if ($this->_config['autoConnect']) {
$this->connect();
}
}
示例3: _init
protected function _init()
{
parent::_init();
unset($this->_config['type']);
foreach ($this->_config as $key => $val) {
if (method_exists($this, $key) && $val !== null) {
$this->_config[$key] = is_array($this->_config[$key]) ? array() : null;
$this->{$key}($val);
}
}
if ($list = $this->_config['whitelist']) {
$this->_config['whitelist'] = array_combine($list, $list);
}
if ($this->_config['with']) {
$this->_associate($this->_config['with']);
}
$joins = $this->_config['joins'];
$this->_config['joins'] = array();
foreach ($joins as $i => $join) {
$this->join($i, $join);
}
if ($this->_entity && !$this->_config['model']) {
$this->model($this->_entity->model());
}
unset($this->_config['entity'], $this->_config['init'], $this->_config['with']);
}
示例4: _init
protected function _init()
{
parent::_init();
$this->_methods += array('GET' => array('view' => 'id', 'index' => null), 'POST' => array('edit' => 'id', 'add' => null), 'PUT' => array('edit' => 'id'), 'PATCH' => array('edit' => 'id'), 'DELETE' => array('delete' => 'id'));
$this->_classes += array('entity' => 'lithium\\data\\Entity', 'response' => 'lithium\\action\\Response', 'resources' => 'li3_resources\\net\\http\\Resources', 'responder' => 'li3_resources\\action\\resource\\Responder');
$this->_responder = $this->_responder ?: $this->_instance('responder');
}
示例5: _init
/**
* Perform initialization.
*
* @return void
*/
protected function _init()
{
Object::_init();
$type = isset($this->_config['type']) ? $this->_config['type'] : null;
if ($type === 'text') {
$h = function ($data) {
return $data;
};
} else {
$encoding = 'UTF-8';
if ($this->_message) {
$encoding =& $this->_message->charset;
}
$h = function ($data) use(&$encoding) {
return htmlspecialchars((string) $data, ENT_QUOTES, $encoding);
};
}
$this->outputFilters += compact('h') + $this->_config['outputFilters'];
foreach (array('loader', 'renderer') as $key) {
if (is_object($this->_config[$key])) {
$this->{'_' . $key} = $this->_config[$key];
continue;
}
$class = $this->_config[$key];
$config = array('view' => $this) + $this->_config;
$path = 'adapter.template.mail';
$instance = Libraries::instance($path, $class, $config);
$this->{'_' . $key} = $instance;
}
}
示例6: _init
/**
* Initializer function called by the constructor unless the constructor
*
* @see lithium\core\Object::_init()
* @throws ConfigException
*/
protected function _init()
{
parent::_init();
if (!$this->_connection) {
throw new ConfigException("The `'connection'` option must be set.");
}
}
示例7: _init
/**
* Initialization of the cookie adapter.
*
* @return void
*/
protected function _init()
{
parent::_init();
if (!$this->_config['name']) {
$this->_config['name'] = Inflector::slug(basename(LITHIUM_APP_PATH)) . 'cookie';
}
}
示例8: _init
protected function _init()
{
parent::_init();
$class = Libraries::locate('socket.util', $this->_classes['socket']);
if (is_string($class)) {
$this->_connection = new $class($this->_config);
}
}
示例9: _init
protected function _init()
{
parent::_init();
$this->_classes += array('router' => 'lithium\\net\\http\\Router', 'resources' => 'li3_resources\\action\\Resources');
$classes = $this->_classes;
$this->_fields += array('$links.self' => function ($entity) use($classes) {
});
}
示例10: _init
/**
* Connect to FTP server on initialization
*/
protected function _init()
{
parent::_init();
if ($this->_config['url'] && substr($this->_config['url'], -1) === '/') {
$this->_config['url'] = rtrim($this->_config['url'], '/');
}
$this->_connect();
}
示例11: _init
/**
* Imports local string definitions into rendering context.
*
* @return void
*/
protected function _init()
{
parent::_init();
if (!$this->_context) {
return;
}
$this->_context->strings($this->_strings);
if ($this->_config['handlers']) {
$this->_context->handlers($this->_config['handlers']);
}
}
示例12: _init
/**
* undocumented function
*
* @return void
*/
protected function _init()
{
parent::_init();
if (empty($this->_file)) {
$this->_file = LITHIUM_APP_PATH . '/resources/oauth/storage/oauth.json';
return;
}
if ($this->_file[0] !== '/') {
$this->_file = LITHIUM_APP_PATH . '/resources/oauth/' . $this->_file;
}
}
示例13: _init
/**
* Sets the default output handlers for string template inputs.
*
* Please note: skips lithium\template\view\Renderer::_init()
* to skip setting handlers.
*
* @return void
*/
protected function _init()
{
Object::_init();
$classes =& $this->_classes;
$message =& $this->_message;
if (!$this->_request && $message) {
$media = $classes['media'];
$this->_request = $media::invokeMethod('_request', array($message));
}
$request =& $this->_request;
$context =& $this->_context;
$h = $this->_view ? $this->_view->outputFilters['h'] : null;
$this->_handlers += array('url' => function ($url, $ref, array $options = array()) use($classes, &$request, $h) {
$router = $classes['router'];
$options += array('absolute' => true);
$url = $router::match($url ?: '', $request, $options);
return $h ? str_replace('&', '&', $h($url)) : $url;
}, 'path' => function ($path, $ref, array $options = array()) use($classes, &$request, &$message) {
$embed = isset($options['embed']) && $options['embed'];
unset($options['embed']);
if ($embed) {
return 'cid:' . $message->embed($path, $options);
} else {
$type = 'generic';
if (is_array($ref) && $ref[0] && $ref[1]) {
list($helper, $methodRef) = $ref;
list($class, $method) = explode('::', $methodRef);
$type = $helper->contentMap[$method];
}
$httpMedia = $classes['http_media'];
$base = $request ? $request->env('base') : '';
$options += compact('base');
$path = $httpMedia::asset($path, $type, $options);
if ($path[0] === '/') {
$host = '';
if ($request) {
$https = $request->env('HTTPS') ? 's' : '';
$host .= "http{$https}://";
$host .= $request->env('HTTP_HOST');
}
$path = $host . $path;
}
return $path;
}
}, 'options' => '_attributes', 'title' => 'escape', 'scripts' => function ($scripts) use(&$context) {
return "\n\t" . join("\n\t", $context['scripts']) . "\n";
}, 'styles' => function ($styles) use(&$context) {
return "\n\t" . join("\n\t", $context['styles']) . "\n";
}, 'head' => function ($head) use(&$context) {
return "\n\t" . join("\n\t", $context['head']) . "\n";
});
unset($this->_config['view']);
}
示例14: _init
protected function _init()
{
parent::_init();
$model = $this->_config['model'];
$behavior = $this;
$this->_config = static::_config($model, $behavior, $this->_config, static::$_defaults);
static::_filters($model, $behavior);
static::_finders($model, $behavior);
if ($methods = static::_methods($model, $behavior)) {
$model::instanceMethods($methods);
}
}
示例15: _init
/**
* Initializer. Populates the `response` property with a new instance of the `Response`
* class passing it configuration and assigns the values from named parameters of the
* request (if applicable) to properties of the command.
*
* @return void
*/
protected function _init()
{
parent::_init();
$this->request = $this->_config['request'];
$this->response = new $this->_classes['response']($this->_config['response']);
if (!empty($this->request->params)) {
$params = (array) array_diff_key($this->request->params, array('command' => null, 'action' => null, 'args' => null));
foreach ($params as $key => $param) {
$this->{$key} = $param;
}
}
}