public function __construct($client) { $this->_client = $client; $this->_cookie = Context::singleton()->tempFile("Browser-Cookie-"); $this->_client->setOpt('COOKIEJAR', $this->_cookie); $this->_client->setOpt('COOKIEFILE', $this->_cookie); }
public static function getEngine() { if (self::$_engine === null) { self::$_engine = new Engine(Context::singleton()); // Engineのセットアップ //self::$_engine->setServiceProvider(new ServiceProvider()); // サービスの組み込み self::$_engine->setService('context', self::Context()); } return self::$_engine; }
public function testBuildUp() { $logger = Logger::build(['name' => 'NoraFile', 'handlers' => [['type' => 'stream', 'path' => '/tmp/nora.%(time|Y-m-d).%(user).log', 'level' => 'warning', 'processer' => [function ($log) { $log['hoge'] = 'huga'; }, function ($log) { $log['ip'] = Context::singleton()->getRemoteIP(); $log['ua'] = Context::singleton()->getUserAgent(); $log['posix_user'] = Context::singleton()->getPosixUser(); }]]]]); $logger->err('エラー'); }
/** * ビルド */ public static function build($name, $dir, $env = ['all', 'dev'], $useCache = true) { $name = $name . '.' . implode('.', $env); if ($useCache) { $file = Context::singleton()->getCachePath("config", $name); if (file_exists($file)) { $c = self::restore($name); $c->_cache = true; return $c; } } $c = new Configuration($name); $c->loadDir($dir, null, $env); $c->_cache = false; $c->save(); return $c; }
public function process(Log $log) { $log['ip'] = Context::singleton()->getRemoteIP(); $log['ua'] = Context::singleton()->getUserAgent(); $log['posix_user'] = Context::singleton()->getPosixUser(); }