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); }
public function __construct($rotate = true, $push = true, $files = 5) { $this->rotate = $rotate; $this->push = $push; $this->files = $files; $this->container = Container::getInstance(); }
/** * Gets container instance * @return object */ private static function getContainer() { if (!static::$container) { static::$container = Container::getInstance(); } return static::$container; }
function app($make = null, $parameters = []) { if (is_null($make)) { return Container::getInstance(); } return Container::getInstance()->make($make, $parameters); }
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); }
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}"); }
/** * 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); }
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); }
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); }
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; }
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); } }
public function __construct() { $this->rule = new Rule(); $this->logger = new Logger(); $this->container = Container::getInstance(); }
public static function hasBean($beanName) { return Container::getInstance()->hasBean($beanName); }
/** * set container instance */ public function __construct() { $this->container = Container::getInstance(); }
/** * 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); }
/** * 核心函数 * 调用类名为className的method函数 * @param String className 类名 * @param String method 调用的函数名 * @param Boolean mul_mod 是否多例模式,默认为单例模式 * @param Boolean is_stat 是否统计 * @return Mixed 成功:目标函数的返回结果;失败:false */ function BaseCall($module, $className, $method, $args, $mul_mod = false, $is_stat = true) { $start = 0; //DEBUG跟踪 global $__core_env; $__core_env['DEBUG'] === true && ($__core_env['STRACE'][$module . "/" . $className . "/" . $method]['start'] = microtime_float()); $object = Container::getInstance()->newObj($module, $className, $mul_mod); if (method_exists($object, $method)) { $result = call_user_func_array(array($object, $method), $args == null ? array() : $args); if ($__core_env['DEBUG'] === true) { $__core_env['STRACE']["{$module}/" . $className . "/" . $method]['end'] = microtime_float(); $__core_env['STRACE']["{$module}/" . $className . "/" . $method]['cost'] = $__core_env['STRACE']["{$module}/" . $className . "/" . $method]['end'] - $__core_env['STRACE']["{$module}/" . $className . "/" . $method]['start']; $__core_env['STRACE']["{$module}/" . $className . "/" . $method]['return'] = $result; } return $result; } else { if ($__core_env['DEBUG'] === true) { $__core_env['STRACE']["{$module}/" . $className . "/" . $method]['end'] = microtime_float(); $__core_env['STRACE']["{$module}/" . $className . "/" . $method]['cost'] = $__core_env['STRACE']["{$module}/" . $className . "/" . $method]['end'] - $__core_env['STRACE']["{$module}/" . $className . "/" . $method]['start']; $__core_env['STRACE']["{$module}/" . $className . "/" . $method]['return'] = "ERROR: The Method {$method} in {$className} is not exist"; echo $__core_env['STRACE']["{$module}/" . $className . "/" . $method]['return']; } //throw new Exception("method not exsit", ) return false; } }
public function __construct($url, $key) { $this->api = new ApiClient($url, $key); $this->logger = new Logger(); $this->container = Container::getInstance(); }
<?php require __DIR__ . '/../vendor/autoload.php'; /* Register Dotenv */ $dotenv = new Dotenv\Dotenv(__DIR__ . '/..'); $dotenv->load(); /* Load Configuration */ $config = (include __DIR__ . '/config.php'); Config::getInstance()->setConfig($config); if ($config['debug']) { /* Register the error handler */ $whoops = new \Whoops\Run(); $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); $whoops->register(); } /* Dependency Injection container */ $container = (include __DIR__ . '/dependencies.php'); Container::getInstance()->setContainer($container); /* Boot Eloquent ORM */ include __DIR__ . '/db.php'; $request = $container->get('request'); $response = $container->get('response'); /* Router & Routes */ $route = new League\Route\RouteCollection($container); include __DIR__ . '/routes.php'; try { $response = $route->dispatch($request, $response); } catch (\League\Route\Http\Exception\NotFoundException $e) { $response->getBody()->write($container->get('templater')->render('errors/404')); } $container->get('emitter')->emit($response);
/** * @depends testUpgradeOneTheme */ public function testUpgradeAllThemes() { global $argv; $argv = array(); $argv[] = 'composer'; $argv[] = 'wp-update'; $argv[] = 'themes'; Container::destroy(); $container = Container::getInstance(); $b = $container->getBootstrap(); $b->update(); $container->getUtils()->includeWordPress(); wp_clean_themes_cache(true); $themes = wp_get_themes(); foreach ($this->tThemes as $key => $versions) { $this->assertTrue(isset($themes[$key])); $this->assertEquals($versions[1], $themes[$key]['Version']); } }
public function __construct($api) { $this->api = $api; $this->logger = new Logger(); $this->container = Container::getInstance(); }
/** * Validate a method name * * @param string $sName The function name * * @return bool True if the method name is valid, and false if not */ public function validateMethod($sName) { return Container::getInstance()->getValidator()->validateMethod($sName); }
protected function getContainer() { return Container::getInstance(); }
public function initializeNotLazyBeans() { foreach ($this->beanToInitialize as $beanName) { Container::getInstance()->getBean($beanName); } }
function container($name) { $container = Container::getInstance()->getContainer(); return $container->get($name); }