emergency() публичный статический Метод

$l is for backward compatibility
public static emergency ( $m, $context = [] )
Пример #1
0
 /**
  * @param bool $forceReload
  * @return mixed|null|\Zend_Config
  * @throws \Zend_Exception
  */
 public static function getSystemConfig($forceReload = false)
 {
     $config = null;
     if (\Zend_Registry::isRegistered("pimcore_config_system") && !$forceReload) {
         $config = \Zend_Registry::get("pimcore_config_system");
     } else {
         try {
             $file = self::locateConfigFile("system.php");
             if (file_exists($file)) {
                 $config = new \Zend_Config(include $file);
             } else {
                 throw new \Exception($file . " doesn't exist");
             }
             self::setSystemConfig($config);
         } catch (\Exception $e) {
             $file = self::locateConfigFile("system.php");
             \Logger::emergency("Cannot find system configuration, should be located at: " . $file);
             if (is_file($file)) {
                 $m = "Your system.php located at " . $file . " is invalid, please check and correct it manually!";
                 Tool::exitWithError($m);
             }
         }
     }
     return $config;
 }
Пример #2
0
 /**
  * @param \Zend_Controller_Request_Abstract $request
  * @throws mixed
  */
 protected function _handleError(\Zend_Controller_Request_Abstract $request)
 {
     // remove zend error handler
     $front = \Zend_Controller_Front::getInstance();
     $front->unregisterPlugin("Zend_Controller_Plugin_ErrorHandler");
     $response = $this->getResponse();
     if ($response->isException() && !$this->_isInsideErrorHandlerLoop) {
         // get errorpage
         try {
             // enable error handler
             $front->setParam('noErrorHandler', false);
             $errorPath = Config::getSystemConfig()->documents->error_pages->default;
             if (Site::isSiteRequest()) {
                 $site = Site::getCurrentSite();
                 $errorPath = $site->getErrorDocument();
             }
             if (empty($errorPath)) {
                 $errorPath = "/";
             }
             $document = Document::getByPath($errorPath);
             if (!$document instanceof Document\Page) {
                 // default is home
                 $document = Document::getById(1);
             }
             if ($document instanceof Document\Page) {
                 $params = Tool::getRoutingDefaults();
                 if ($module = $document->getModule()) {
                     $params["module"] = $module;
                 }
                 if ($controller = $document->getController()) {
                     $params["controller"] = $controller;
                     $params["action"] = "index";
                 }
                 if ($action = $document->getAction()) {
                     $params["action"] = $action;
                 }
                 $this->setErrorHandler($params);
                 $request->setParam("document", $document);
                 \Zend_Registry::set("pimcore_error_document", $document);
                 // ensure that a viewRenderer exists, and is enabled
                 if (!\Zend_Controller_Action_HelperBroker::hasHelper("viewRenderer")) {
                     $viewRenderer = new \Pimcore\Controller\Action\Helper\ViewRenderer();
                     \Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
                 }
                 $viewRenderer = \Zend_Controller_Action_HelperBroker::getExistingHelper("viewRenderer");
                 $viewRenderer->setNoRender(false);
                 if ($viewRenderer->view === null) {
                     $viewRenderer->initView(PIMCORE_WEBSITE_PATH . "/views");
                 }
             }
         } catch (\Exception $e) {
             Logger::emergency("error page not found");
         }
     }
     // call default ZF error handler
     parent::_handleError($request);
 }
Пример #3
0
 /**
  * @static
  * @return \Zend_Config
  */
 public static function getSystemConfig()
 {
     $config = null;
     if (\Zend_Registry::isRegistered("pimcore_config_system")) {
         $config = \Zend_Registry::get("pimcore_config_system");
     } else {
         try {
             $config = new \Zend_Config_Xml(PIMCORE_CONFIGURATION_SYSTEM);
             self::setSystemConfig($config);
         } catch (\Exception $e) {
             \Logger::emergency("Cannot find system configuration, should be located at: " . PIMCORE_CONFIGURATION_SYSTEM);
             if (is_file(PIMCORE_CONFIGURATION_SYSTEM)) {
                 $m = "Your system.xml located at " . PIMCORE_CONFIGURATION_SYSTEM . " is invalid, please check and correct it manually!";
                 Tool::exitWithError($m);
             }
         }
     }
     return $config;
 }
Пример #4
0
 /**
  * @param bool $forceReload
  * @return array|null
  */
 public static function getWorkflowManagementConfig($forceReload = false)
 {
     $config = null;
     if (\Zend_Registry::isRegistered("pimcore_config_workflowmanagement") && !$forceReload) {
         $config = \Zend_Registry::get("pimcore_config_workflowmanagement");
     } else {
         try {
             $file = \Pimcore\Config::locateConfigFile("workflowmanagement.php");
             if (is_file($file)) {
                 $config = (include $file);
                 if (is_array($config)) {
                     self::setWorkflowManagementConfig($config);
                 } else {
                     Logger::error("{$file} exists but it is not a valid PHP array configuration.");
                 }
             }
         } catch (\Exception $e) {
             $file = \Pimcore\Config::locateConfigFile("workflowmanagement.php");
             Logger::emergency("Cannot find workflow configuration, should be located at: " . $file);
         }
     }
     return $config;
 }
Пример #5
0
 /**
  * @param string $namespace
  * @param bool $readOnly
  * @return \Zend_Session_Namespace
  * @throws \Zend_Session_Exception
  */
 public static function get($namespace = "pimcore_admin", $readOnly = false)
 {
     $initSession = !\Zend_Session::isStarted();
     $forceStart = !$readOnly;
     // we don't force the session to start in read-only mode (default behavior)
     $sName = self::getOption("name");
     if (self::backupForeignSession()) {
         $initSession = true;
         $forceStart = true;
     }
     if ($initSession) {
         \Zend_Session::setOptions(self::$options);
     }
     try {
         try {
             if ($initSession) {
                 // only set the session id if the cookie isn't present, otherwise Set-Cookie is always in the headers
                 if (array_key_exists($sName, $_REQUEST) && !empty($_REQUEST[$sName]) && (!array_key_exists($sName, $_COOKIE) || empty($_COOKIE[$sName]))) {
                     // get zend_session work with session-id via get (since SwfUpload doesn't support cookies)
                     \Zend_Session::setId($_REQUEST[$sName]);
                 }
             }
         } catch (\Exception $e) {
             Logger::error("Problem while starting session");
             Logger::error($e);
         }
     } catch (\Exception $e) {
         Logger::emergency("there is a problem with admin session");
         die;
     }
     if ($initSession) {
         \Zend_Session::start();
     }
     if ($forceStart) {
         @session_start();
         self::$sessionCookieCleanupNeeded = true;
     }
     if (!array_key_exists($namespace, self::$sessions) || !self::$sessions[$namespace] instanceof \Zend_Session_Namespace) {
         try {
             self::$sessions[$namespace] = new Session\Container($namespace);
         } catch (\Exception $e) {
             // invalid session, regenerate the session, and return a dummy object
             \Zend_Session::regenerateId();
             return new \stdClass();
         }
     }
     self::$openedSessions++;
     self::$sessions[$namespace]->unlock();
     return self::$sessions[$namespace];
 }
Пример #6
0
 /**
  * @static
  * @return mixed|\Zend_Db_Adapter_Abstract
  */
 public static function get()
 {
     try {
         if (\Zend_Registry::isRegistered("Pimcore_Db")) {
             $connection = \Zend_Registry::get("Pimcore_Db");
             if ($connection instanceof Wrapper) {
                 return $connection;
             }
         }
     } catch (\Exception $e) {
         \Logger::error($e);
     }
     // get new connection
     try {
         $db = self::getConnection();
         self::set($db);
         return $db;
     } catch (\Exception $e) {
         $errorMessage = "Unable to establish the database connection with the given configuration in /website/var/config/system.xml, for details see the debug.log. \nReason: " . $e->getMessage();
         \Logger::emergency($errorMessage);
         \Logger::emergency($e);
         \Pimcore\Tool::exitWithError($errorMessage);
     }
 }
Пример #7
0
 /**
  * @param $method
  * @param $args
  * @return mixed
  * @throws \Exception
  */
 public function __call($method, $args)
 {
     // protected / private methods shouldn't be delegated to the dao -> this can have dangerous effects
     if (!is_callable([$this, $method])) {
         throw new \Exception("Unable to call private/protected method '" . $method . "' on object " . get_class($this));
     }
     // check if the method is defined in ´dao
     if (method_exists($this->getDao(), $method)) {
         try {
             $r = call_user_func_array([$this->getDao(), $method], $args);
             return $r;
         } catch (\Exception $e) {
             Logger::emergency($e);
             throw $e;
         }
     } else {
         Logger::error("Class: " . get_class($this) . " => call to undefined method " . $method);
         throw new \Exception("Call to undefined method " . $method . " in class " . get_class($this));
     }
 }