本文整理汇总了PHP中Container::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::getInstance方法的具体用法?PHP Container::getInstance怎么用?PHP Container::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Container
的用法示例。
在下文中一共展示了Container::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onNotFound
public function onNotFound(\Event $event)
{
$controller = new \Controller(\App::getInstance());
$page = $controller->twigInit()->render(\Config::get('view::notfound_page'));
$response = new \Response($page, 404);
\Container::getInstance()->setResponse($response);
}
示例2: __construct
public function __construct($rotate = true, $push = true, $files = 5)
{
$this->rotate = $rotate;
$this->push = $push;
$this->files = $files;
$this->container = Container::getInstance();
}
示例3: getContainer
/**
* Gets container instance
* @return object
*/
private static function getContainer()
{
if (!static::$container) {
static::$container = Container::getInstance();
}
return static::$container;
}
示例4: app
function app($make = null, $parameters = [])
{
if (is_null($make)) {
return Container::getInstance();
}
return Container::getInstance()->make($make, $parameters);
}
示例5: writeLog
public static function writeLog($level, $message, $context, $model)
{
$logger = new Logger($model);
$env = \Container::getInstance()->getEnvironment();
$logger->pushHandler(new StreamHandler(static::$cache_dir . '/' . $env . '.log', self::$levels[$level]));
$logger->pushHandler(new FirePHPHandler());
return $logger->{$level}($message, $context);
}
示例6: __construct
public function __construct()
{
$path = \Container::getInstance()->getAppPath();
require_once $path . 'vendor/hprose/hprose/src/Hprose.php';
$type = \Config::get('rpc::current_server');
$server = \Config::get('rpc::server');
$host = $server[$type]['host'];
$port = $server[$type]['port'];
$this->client = new \HproseSwooleClient("{$type}://{$host}:{$port}");
}
示例7: cache
/**
* Get / set the specified cache value.
*
* If an array is passed as the key, we will assume you want to set an array of values.
*
* @param array|string $key
* @param mixed $default
*
* @return mixed
*/
function cache($key = null, $default = null)
{
if (is_null($key)) {
return Container::getInstance()->make('cache');
}
if (is_array($key)) {
return Container::getInstance()->make('cache')->put($key);
}
return Container::getInstance()->make('cache')->get($key, $default);
}
示例8: resolveStatique
protected static function resolveStatique($name)
{
if (is_object($name)) {
return $name;
}
if (isset(static::$resolvedInstance[$name])) {
return static::$resolvedInstance[$name];
}
return static::$resolvedInstance[$name] = Container::getInstance()->make($name);
}
示例9: __construct
public function __construct($arguments)
{
$this->run = isset($arguments['e']) ? trim($arguments['e']) : false;
$this->uid = isset($arguments['p']) ? trim($arguments['p']) : false;
$this->ref = isset($arguments['r']) ? trim($arguments['r']) : false;
$this->mail = isset($arguments['m']) ? trim($arguments['m']) : false;
$this->history = isset($arguments['h']) ? trim($arguments['h']) : false;
$this->limit = isset($arguments['l']);
$this->update = isset($arguments['u']);
$this->custom = isset($arguments['c']);
$this->debug = isset($arguments['d']);
$this->container = Container::getInstance();
$this->api = new RequestProxy($this->container->settings['api']['url'], $this->container->settings['api']['key']);
$this->requestHelper = new ApiHelper($this->api);
}
示例10: get
public static function get($key)
{
// app.slack.token
$parts = explode('.', $key);
$container = Container::getInstance();
$base = $container->{'config.' . $parts[0]};
unset($parts[0]);
foreach ($parts as $part) {
if (isset($base[$part])) {
$base = $base[$part];
} else {
return null;
}
}
return $base;
}
示例11: __construct
public function __construct($mailBox)
{
$this->container = Container::getInstance();
$this->rule = new Rule();
$this->mailBox = $mailBox;
if (is_array($this->container->mail)) {
if (isset($this->container->mail[$mailBox])) {
$this->mailSettings = explode(',', $this->container->mail[$mailBox]);
} else {
CommandHelper::settingsFailure($mailBox);
exit(1);
}
} else {
CommandHelper::activateNotice('mail');
exit(1);
}
}
示例12: __construct
public function __construct()
{
$this->rule = new Rule();
$this->logger = new Logger();
$this->container = Container::getInstance();
}
示例13: hasBean
public static function hasBean($beanName)
{
return Container::getInstance()->hasBean($beanName);
}
示例14: __construct
/**
* set container instance
*/
public function __construct()
{
$this->container = Container::getInstance();
}
示例15: __construct
/**
* DIContainer constructor.
* @param array $config
*/
protected function __construct(array $config)
{
$this->config = $this->createFlatConfig($config);
$this->services['service.di_container'] =& $this;
$this->services['service.container'] = Container::getInstance($config);
}