本文整理汇总了PHP中AppContext::service方法的典型用法代码示例。如果您正苦于以下问题:PHP AppContext::service方法的具体用法?PHP AppContext::service怎么用?PHP AppContext::service使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppContext
的用法示例。
在下文中一共展示了AppContext::service方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resolveViewName
function resolveViewName($viewName, $locale)
{
if (!AppContext::service_exists($viewName)) {
// Allow for ViewResolver chaining.
return null;
}
return AppContext::service($viewName);
}
示例2: log_enabled
function log_enabled($level)
{
$log =& AppContext::service('Log');
if ($log != null) {
return $log->enabled($level);
} else {
return false;
}
}
示例3: HandlerExecutionChain
function &getHandler(&$request)
{
$handler =& $this->getHandlerInternal($request);
if ($handler == null) {
$handler =& $this->defaultHandler;
}
if ($handler == null) {
return $handler;
}
// Service name or resolved handler?
if (is_string($handler)) {
$handler =& AppContext::service($handler);
}
$hec =& new HandlerExecutionChain(&$handler, &$this->interceptors);
return $hec;
}
示例4: _resolveService
function _resolveService($serviceName)
{
if ($this->{$serviceName} == NULL) {
$this->{$serviceName} =& AppContext::service($serviceName);
if ($this->{$serviceName} == NULL) {
$this->{$serviceName} =& $this->_getDefaultStrategy($serviceName);
}
}
if (log_enabled(LOG_DEBUG)) {
log_message(LOG_DEBUG, 'Using ' . $serviceName . ' [' . get_class($this->{$serviceName}) . ']');
}
}
示例5: _null
function &instantiate()
{
if ($this->className == null) {
return _null();
}
if (!class_exists($this->className)) {
if (!is_file($this->base . $this->filename) || !file_exists($this->base . $this->filename)) {
show_error('Instantiator Error', "File not found for '{$this->className}': " . $this->base . $this->filename);
}
include $this->base . $this->filename;
}
$class = $this->className;
if (!is_array($this->definition)) {
$instance =& new $class();
} else {
# parameters
$parameters = false;
if (isset($this->definition['parameters'])) {
if (!is_array($parameters = $this->definition['parameters'])) {
$parameters = array($parameters);
}
}
# instantiate
if (!$parameters) {
$instance =& new $class();
} else {
$instance =& $this->_create_obj_array($class, $parameters);
}
# autowire?
if (isset($this->definition['autowire']) && $this->definition['autowire'] == true) {
$vars = get_object_vars($instance);
foreach ($vars as $name => $val) {
$service =& AppContext::service($name);
if ($service != null) {
$instance->{$name} =& $service;
}
}
}
# properties
if (isset($this->definition['properties'])) {
$properties = array_map(array(&$this, '_get_typed_value'), $this->definition['properties']);
foreach ($properties as $name => $value) {
$instance->{$name} =& $properties[$name];
}
}
# invoke
if (isset($this->definition['invoke'])) {
foreach ($this->definition['invoke'] as $name => $value) {
if (!is_array($value)) {
$value = array($value);
}
call_user_func_array(array(&$instance, $name), $value);
}
}
# initialize-method
if (isset($this->definition['initialize-method'])) {
call_user_func(array(&$instance, $this->definition['initialize-method']));
}
}
return $instance;
}