当前位置: 首页>>代码示例>>PHP>>正文


PHP Session::getReadOnly方法代码示例

本文整理汇总了PHP中Pimcore\Tool\Session::getReadOnly方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::getReadOnly方法的具体用法?PHP Session::getReadOnly怎么用?PHP Session::getReadOnly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pimcore\Tool\Session的用法示例。


在下文中一共展示了Session::getReadOnly方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: authenticateSession

 /**
  * @static
  * @throws Exception
  * @return User
  */
 public static function authenticateSession()
 {
     if (!isset($_COOKIE["pimcore_admin_sid"]) && !isset($_REQUEST["pimcore_admin_sid"])) {
         // if no session cookie / ID no authentication possible, we don't need to start a session
         return null;
     }
     $session = Session::getReadOnly();
     $user = $session->user;
     if ($user instanceof User) {
         // renew user
         $user = User::getById($user->getId());
         if (self::isValidUser($user)) {
             return $user;
         }
     }
     return null;
 }
开发者ID:rolandstoll,项目名称:pimcore,代码行数:22,代码来源:Authentication.php

示例2: previewAction

 public function previewAction()
 {
     $id = $this->getParam("id");
     $key = "object_" . $id;
     $session = Tool\Session::getReadOnly("pimcore_objects");
     if ($session->{$key}) {
         $object = $session->{$key};
     } else {
         die("Preview not available, it seems that there's a problem with this object.");
     }
     $url = $object->getClass()->getPreviewUrl();
     // replace named variables
     $vars = get_object_vars($object);
     foreach ($vars as $key => $value) {
         if (!empty($value) && (is_string($value) || is_numeric($value))) {
             $url = str_replace("%" . $key, urlencode($value), $url);
         } else {
             if (strpos($url, "%" . $key) !== false) {
                 die("No preview available, please ensure that all fields which are required for the preview are filled correctly.");
             }
         }
     }
     // replace all remainaing % signs
     $url = str_replace("%", "%25", $url);
     $urlParts = parse_url($url);
     $this->redirect($urlParts["path"] . "?pimcore_object_preview=" . $id . "&_dc=" . time() . "&" . $urlParts["query"]);
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:27,代码来源:ObjectController.php

示例3: init

 /**
  * @throws \Zend_Controller_Router_Exception
  */
 public function init()
 {
     // this is only executed once per request (first request)
     if (self::$isInitial) {
         \Pimcore::getEventManager()->trigger("frontend.controller.preInit", $this);
     }
     parent::init();
     // log exceptions if handled by error_handler
     $this->checkForErrors();
     // general definitions
     if (self::$isInitial) {
         \Pimcore::unsetAdminMode();
         Document::setHideUnpublished(true);
         Object\AbstractObject::setHideUnpublished(true);
         Object\AbstractObject::setGetInheritedValues(true);
         Object\Localizedfield::setGetFallbackValues(true);
     }
     // assign variables
     $this->view->controller = $this;
     // init website config
     $config = Config::getWebsiteConfig();
     $this->config = $config;
     $this->view->config = $config;
     $document = $this->getParam("document");
     if (!$document instanceof Document) {
         \Zend_Registry::set("pimcore_editmode", false);
         $this->editmode = false;
         $this->view->editmode = false;
         self::$isInitial = false;
         // check for a locale first, and set it if available
         if ($this->getParam("pimcore_parentDocument")) {
             // this is a special exception for renderlets in editmode (ajax request), because they depend on the locale of the parent document
             // otherwise there'll be notices like:  Notice: 'No translation for the language 'XX' available.'
             if ($parentDocument = Document::getById($this->getParam("pimcore_parentDocument"))) {
                 if ($parentDocument->getProperty("language")) {
                     $this->setLocaleFromDocument($parentDocument->getProperty("language"));
                 }
             }
         }
         // no document available, continue, ...
         return;
     } else {
         $this->setDocument($document);
         // register global locale if the document has the system property "language"
         if ($this->getDocument()->getProperty("language")) {
             $this->setLocaleFromDocument($this->getDocument()->getProperty("language"));
         }
         if (self::$isInitial) {
             // append meta-data to the headMeta() view helper,  if it is a document-request
             if (!Model\Staticroute::getCurrentRoute() && $this->getDocument() instanceof Document\Page) {
                 if (is_array($this->getDocument()->getMetaData())) {
                     foreach ($this->getDocument()->getMetaData() as $meta) {
                         // only name
                         if (!empty($meta["idName"]) && !empty($meta["idValue"]) && !empty($meta["contentValue"])) {
                             $method = "append" . ucfirst($meta["idName"]);
                             $this->view->headMeta()->{$method}($meta["idValue"], $meta["contentValue"]);
                         }
                     }
                 }
             }
         }
     }
     // this is only executed once per request (first request)
     if (self::$isInitial) {
         // contains the logged in user if necessary
         $user = null;
         // default is to set the editmode to false, is enabled later if necessary
         \Zend_Registry::set("pimcore_editmode", false);
         if (Tool::isFrontentRequestByAdmin()) {
             $this->disableBrowserCache();
             // start admin session & get logged in user
             $user = Authentication::authenticateSession();
         }
         if (\Pimcore::inDebugMode()) {
             $this->disableBrowserCache();
         }
         if (!$this->document->isPublished()) {
             if (Tool::isFrontentRequestByAdmin()) {
                 if (!$user) {
                     throw new \Zend_Controller_Router_Exception("access denied for " . $this->document->getFullPath());
                 }
             } else {
                 throw new \Zend_Controller_Router_Exception("access denied for " . $this->document->getFullPath());
             }
         }
         // logged in users only
         if ($user) {
             // set the user to registry so that it is available via \Pimcore\Tool\Admin::getCurrentUser();
             \Zend_Registry::set("pimcore_admin_user", $user);
             // document editmode
             if ($this->getParam("pimcore_editmode")) {
                 \Zend_Registry::set("pimcore_editmode", true);
                 // check if there is the document in the session
                 $docKey = "document_" . $this->getDocument()->getId();
                 $docSession = Session::getReadOnly("pimcore_documents");
                 if ($docSession->{$docKey}) {
                     // if there is a document in the session use it
//.........这里部分代码省略.........
开发者ID:tododo,项目名称:pimcore,代码行数:101,代码来源:Frontend.php


注:本文中的Pimcore\Tool\Session::getReadOnly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。