Esempio n. 1
0
 public static function create(Context $context)
 {
     if ($context->useHtmlOutput()) {
         return new WriterForWeb($context);
     }
     return new WriterForCLI($context);
 }
Esempio n. 2
0
 public function __construct($name, SystemContext $context, $dir)
 {
     $this->_context = new Context($context, $dir);
     // ConfigPathを設定
     $configPath = $this->_context->getFilePath('config');
     // Configを作成
     $this->_config = Configuration::build('module.' . $name, $configPath, $context->getVal('env'), $useCache = false);
     // AutoLoader
     $ns = $this->_config->read('namespace', $context->getService('config')->read('module.namespace') . '\\' . ucfirst($name));
     $this->_context->setVal('ns', $ns);
     $context->getService('autoloader')->register([$ns . '\\Controller' => $this->_context->getFilePath('controller'), $this->_context->getFilePath('lib')]);
 }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
 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('エラー');
 }
Esempio n. 6
0
 /**
  * ビルド
  */
 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;
 }
Esempio n. 7
0
 public function __construct(SystemContext $context)
 {
     $this->_context = $context;
     $this->_module_dir = $context->getFilePath($context->getService('config')->read('module.dir', 'modules'));
 }
Esempio n. 8
0
 public function process(Log $log)
 {
     $log['ip'] = Context::singleton()->getRemoteIP();
     $log['ua'] = Context::singleton()->getUserAgent();
     $log['posix_user'] = Context::singleton()->getPosixUser();
 }
Esempio n. 9
0
 public function __construct(Context $context)
 {
     $this->_context = $context;
     $this->_debugger = $context->getService('debugger');
     $this->_output = $context->getService('output');
 }