Пример #1
0
 /**
  * @param string $level
  * @param string $message
  */
 private function writeLog($level, $message)
 {
     if (!empty($message)) {
         if ($this->file === null) {
             $this->file = $this->container->getConfig()->get('log.error');
         }
         $content = date('Y-m-d H:i:s') . ' ' . $level . ': ' . $message . PHP_EOL;
         file_put_contents($this->file, $content, FILE_APPEND);
     }
 }
Пример #2
0
 public function configure()
 {
     $config = $this->container->getConfig();
     if ($config->get('app.timezone')) {
         date_default_timezone_set($config->get('app.timezone'));
     }
     if ($this->container->getConfig()->get('app.debug')) {
         error_reporting(E_ALL);
         ini_set('display_errors', "On");
     } else {
         $errorHandler = new ErrorHandler($this->container->getErrorLogger());
         set_error_handler([$errorHandler, 'error']);
         set_exception_handler([$errorHandler, 'exception']);
         register_shutdown_function([$errorHandler, 'shutdown']);
     }
 }
Пример #3
0
 private function detectTravis()
 {
     $travis = getenv('TRAVIS');
     if ($travis) {
         $this->container->getApp()->setEnv(App::TRAVIS_ENV);
         $this->container->getConfig()->setEnvironment('travis');
     } elseif (is_array($_SERVER)) {
         foreach ($_SERVER as $key => $value) {
             if (stripos($key, 'TRAVIS') !== false) {
                 $this->container->getApp()->setEnv(App::TRAVIS_ENV);
                 $this->container->getConfig()->setEnvironment('travis');
                 break;
             }
         }
     }
 }
Пример #4
0
 /**
  * @return bool
  */
 private function changeUser()
 {
     $user = $this->container->getConfig()->get('command.user');
     // Bypass cache commands as we need the sudoer user to run the commands
     if (null !== $user && (!isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] !== 'flushall') && (!isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] !== 'redis:flushall') && (!isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] !== 'apc:flushall')) {
         $name = $user;
         $user = posix_getpwnam($user);
         posix_setgid($user['gid']);
         posix_setuid($user['uid']);
         if (posix_geteuid() !== (int) $user['uid']) {
             $output = new ConsoleOutput();
             $formatter = new FormatterHelper();
             $output->writeln('', true);
             $errorMessages = array('', ' [Error] ', ' Could not change user to ' . $name . ' ', '');
             $formattedBlock = $formatter->formatBlock($errorMessages, 'error');
             $output->writeln($formattedBlock);
             $output->writeln('', true);
             return false;
         }
     }
     return true;
 }
Пример #5
0
 /**
  * @return Config
  */
 public function getConfig()
 {
     return $this->container->getConfig();
 }