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


PHP Service::getSafeVersionInfo方法代码示例

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


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

示例1: getDataByIdAction

 public function getDataByIdAction()
 {
     // check for lock
     if (Element\Editlock::isLocked($this->getParam("id"), "document")) {
         $this->_helper->json(["editlock" => Element\Editlock::getByElement($this->getParam("id"), "document")]);
     }
     Element\Editlock::lock($this->getParam("id"), "document");
     $email = Document\Newsletter::getById($this->getParam("id"));
     $email = clone $email;
     $email = $this->getLatestVersion($email);
     $versions = Element\Service::getSafeVersionInfo($email->getVersions());
     $email->setVersions(array_splice($versions, 0, 1));
     $email->idPath = Element\Service::getIdPath($email);
     $email->userPermissions = $email->getUserPermissions();
     $email->setLocked($email->isLocked());
     $email->setParent(null);
     // unset useless data
     $email->setElements(null);
     $email->childs = null;
     $this->addTranslationsData($email);
     $this->minimizeProperties($email);
     //Hook for modifying return value - e.g. for changing permissions based on object data
     //data need to wrapped into a container in order to pass parameter to event listeners by reference so that they can change the values
     $returnValueContainer = new \Pimcore\Model\Tool\Admin\EventDataContainer(object2array($email));
     \Pimcore::getEventManager()->trigger("admin.document.get.preSendData", $this, ["document" => $email, "returnValueContainer" => $returnValueContainer]);
     if ($email->isAllowed("view")) {
         $this->_helper->json($returnValueContainer->getData());
     }
     $this->_helper->json(false);
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:30,代码来源:NewsletterController.php

示例2: getVersionsAction

 /**
  * @throws \Exception
  */
 public function getVersionsAction()
 {
     $id = intval($this->getParam("id"));
     $type = $this->getParam("controller");
     $allowedTypes = ["asset", "document", "object"];
     if ($id && in_array($type, $allowedTypes)) {
         $element = Model\Element\Service::getElementById($type, $id);
         if ($element) {
             if ($element->isAllowed("versions")) {
                 $schedule = $element->getScheduledTasks();
                 $schedules = [];
                 foreach ($schedule as $task) {
                     if ($task->getActive()) {
                         $schedules[$task->getVersion()] = $task->getDate();
                     }
                 }
                 $versions = $element->getVersions();
                 $versions = Model\Element\Service::getSafeVersionInfo($versions);
                 foreach ($versions as &$version) {
                     $version["scheduled"] = null;
                     if (array_key_exists($version["id"], $schedules)) {
                         $version["scheduled"] = $schedules[$version["id"]];
                     }
                 }
                 $this->_helper->json(["versions" => $versions]);
             } else {
                 throw new \Exception("Permission denied, " . $type . " id [" . $id . "]");
             }
         } else {
             throw new \Exception($type . " with id [" . $id . "] doesn't exist");
         }
     }
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:36,代码来源:Element.php

示例3: getAction

 public function getAction()
 {
     // check for lock
     if (Element\Editlock::isLocked($this->getParam("id"), "object")) {
         $this->_helper->json(["editlock" => Element\Editlock::getByElement($this->getParam("id"), "object")]);
     }
     Element\Editlock::lock($this->getParam("id"), "object");
     $object = Object::getById(intval($this->getParam("id")));
     $object = clone $object;
     // set the latest available version for editmode
     $latestObject = $this->getLatestVersion($object);
     // we need to know if the latest version is published or not (a version), because of lazy loaded fields in $this->getDataForObject()
     $objectFromVersion = $latestObject === $object ? false : true;
     $object = $latestObject;
     if ($object->isAllowed("view")) {
         $objectData = [];
         $objectData["idPath"] = Element\Service::getIdPath($object);
         $objectData["previewUrl"] = $object->getClass()->getPreviewUrl();
         $objectData["general"] = [];
         $allowedKeys = ["o_published", "o_key", "o_id", "o_modificationDate", "o_creationDate", "o_classId", "o_className", "o_locked", "o_type", "o_parentId", "o_userOwner", "o_userModification"];
         foreach (get_object_vars($object) as $key => $value) {
             if (strstr($key, "o_") && in_array($key, $allowedKeys)) {
                 $objectData["general"][$key] = $value;
             }
         }
         $objectData["general"]["o_locked"] = $object->isLocked();
         $this->getDataForObject($object, $objectFromVersion);
         $objectData["data"] = $this->objectData;
         $objectData["metaData"] = $this->metaData;
         $objectData["layout"] = $object->getClass()->getLayoutDefinitions();
         $objectData["properties"] = Element\Service::minimizePropertiesForEditmode($object->getProperties());
         $objectData["userPermissions"] = $object->getUserPermissions();
         $objectVersions = Element\Service::getSafeVersionInfo($object->getVersions());
         $objectData["versions"] = array_splice($objectVersions, 0, 1);
         $objectData["scheduledTasks"] = $object->getScheduledTasks();
         $objectData["general"]["allowVariants"] = $object->getClass()->getAllowVariants();
         $objectData["general"]["showVariants"] = $object->getClass()->getShowVariants();
         $objectData["general"]["fullpath"] = $object->getRealFullPath();
         if ($object->getElementAdminStyle()->getElementIcon()) {
             $objectData["general"]["icon"] = $object->getElementAdminStyle()->getElementIcon();
         }
         if ($object->getElementAdminStyle()->getElementIconClass()) {
             $objectData["general"]["iconCls"] = $object->getElementAdminStyle()->getElementIconClass();
         }
         if ($object instanceof Object\Concrete) {
             $objectData["lazyLoadedFields"] = $object->getLazyLoadedFields();
         }
         $objectData["childdata"]["id"] = $object->getId();
         $objectData["childdata"]["data"]["classes"] = $this->prepareChildClasses($object->getDao()->getClasses());
         $currentLayoutId = $this->getParam("layoutId", null);
         $validLayouts = Object\Service::getValidLayouts($object);
         //master layout has id 0 so we check for is_null()
         if (is_null($currentLayoutId) && !empty($validLayouts)) {
             foreach ($validLayouts as $checkDefaultLayout) {
                 if ($checkDefaultLayout->getDefault()) {
                     $currentLayoutId = $checkDefaultLayout->getId();
                 }
             }
         }
         if (!empty($validLayouts)) {
             $objectData["validLayouts"] = [];
             foreach ($validLayouts as $validLayout) {
                 $objectData["validLayouts"][] = ["id" => $validLayout->getId(), "name" => $validLayout->getName()];
             }
             $user = Tool\Admin::getCurrentUser();
             if ($currentLayoutId == 0 && !$user->isAdmin()) {
                 $first = reset($validLayouts);
                 $currentLayoutId = $first->getId();
             }
             if ($currentLayoutId > 0) {
                 // check if user has sufficient rights
                 if ($validLayouts && $validLayouts[$currentLayoutId]) {
                     $customLayout = Object\ClassDefinition\CustomLayout::getById($currentLayoutId);
                     $customLayoutDefinition = $customLayout->getLayoutDefinitions();
                     $objectData["layout"] = $customLayoutDefinition;
                 } else {
                     $currentLayoutId = 0;
                 }
             } elseif ($currentLayoutId == -1 && $user->isAdmin()) {
                 $layout = Object\Service::getSuperLayoutDefinition($object);
                 $objectData["layout"] = $layout;
             }
             $objectData["currentLayoutId"] = $currentLayoutId;
         }
         $objectData = $this->filterLocalizedFields($object, $objectData);
         Object\Service::enrichLayoutDefinition($objectData["layout"], $object);
         //Hook for modifying return value - e.g. for changing permissions based on object data
         //data need to wrapped into a container in order to pass parameter to event listeners by reference so that they can change the values
         $returnValueContainer = new Model\Tool\Admin\EventDataContainer($objectData);
         \Pimcore::getEventManager()->trigger("admin.object.get.preSendData", $this, ["object" => $object, "returnValueContainer" => $returnValueContainer]);
         $this->_helper->json($returnValueContainer->getData());
     } else {
         Logger::debug("prevented getting object id [ " . $object->getId() . " ] because of missing permissions");
         $this->_helper->json(["success" => false, "message" => "missing_permission"]);
     }
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:96,代码来源:ObjectController.php


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