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


PHP Service::enrichLayoutDefinition方法代码示例

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


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

示例1: getAction

 public function getAction()
 {
     // check for lock
     if (Element\Editlock::isLocked($this->getParam("id"), "object")) {
         $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "object")));
     }
     Element\Editlock::lock($this->getParam("id"), "object");
     $object = Object::getById(intval($this->getParam("id")));
     // 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 = array();
         $objectData["idPath"] = Element\Service::getIdPath($object);
         $objectData["previewUrl"] = $object->getClass()->getPreviewUrl();
         $objectData["general"] = array();
         $allowedKeys = array("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();
         $objectData["versions"] = array_splice($object->getVersions(), 0, 1);
         $objectData["scheduledTasks"] = $object->getScheduledTasks();
         $objectData["general"]["allowVariants"] = $object->getClass()->getAllowVariants();
         $objectData["general"]["showVariants"] = $object->getClass()->getShowVariants();
         $objectData["general"]["fullpath"] = $object->getFullPath();
         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"] = $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"] = array();
             foreach ($validLayouts as $validLayout) {
                 $objectData["validLayouts"][] = array("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(array("success" => false, "message" => "missing_permission"));
     }
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:94,代码来源:ObjectController.php

示例2: adminElementGetPreSendData

 /**
  * Fired before information is sent back to the admin UI about an element
  * @param \Zend_EventManager_Event $e
  * @throws \Exception
  */
 public static function adminElementGetPreSendData($e)
 {
     $element = self::extractElementFromEvent($e);
     $returnValueContainer = $e->getParam('returnValueContainer');
     $data = $returnValueContainer->getData();
     //create a new namespace for WorkflowManagement
     //set some defaults
     $data['workflowManagement'] = ['hasWorkflowManagement' => false];
     if (Workflow\Manager::elementCanAction($element)) {
         $data['workflowManagement']['hasWorkflowManagement'] = true;
         //see if we can change the layout
         $currentUser = Admin::getCurrentUser();
         $manager = Workflow\Manager\Factory::getManager($element, $currentUser);
         $data['workflowManagement']['workflowName'] = $manager->getWorkflow()->getName();
         //get the state and status
         $state = $manager->getElementState();
         $data['workflowManagement']['state'] = $manager->getWorkflow()->getStateConfig($state);
         $status = $manager->getElementStatus();
         $data['workflowManagement']['status'] = $manager->getWorkflow()->getStatusConfig($status);
         if ($element instanceof ConcreteObject) {
             $workflowLayoutId = $manager->getObjectLayout();
             //check for !is_null here as we might want to specify 0 in the workflow config
             if (!is_null($workflowLayoutId)) {
                 //load the new layout into the object container
                 $validLayouts = Object\Service::getValidLayouts($element);
                 //check that the layout id is valid before trying to load
                 if (!empty($validLayouts)) {
                     //todo check user permissions again
                     if ($validLayouts && $validLayouts[$workflowLayoutId]) {
                         $customLayout = ClassDefinition\CustomLayout::getById($workflowLayoutId);
                         $customLayoutDefinition = $customLayout->getLayoutDefinitions();
                         Object\Service::enrichLayoutDefinition($customLayoutDefinition, $e->getParam('object'));
                         $data["layout"] = $customLayoutDefinition;
                     }
                 }
             }
         }
     }
     $returnValueContainer->setData($data);
 }
开发者ID:solverat,项目名称:pimcore,代码行数:45,代码来源:EventHandler.php

示例3: getFieldGridConfig

 protected function getFieldGridConfig($field, $gridType, $position, $force = false, $keyPrefix = null)
 {
     $key = $keyPrefix . $field->getName();
     $config = null;
     $title = $field->getName();
     if (method_exists($field, "getTitle")) {
         if ($field->getTitle()) {
             $title = $field->getTitle();
         }
     }
     if ($field->getFieldType() == "slider") {
         $config["minValue"] = $field->getMinValue();
         $config["maxValue"] = $field->getMaxValue();
         $config["increment"] = $field->getIncrement();
     }
     if (method_exists($field, "getWidth")) {
         $config["width"] = $field->getWidth();
     }
     if (method_exists($field, "getHeight")) {
         $config["height"] = $field->getHeight();
     }
     $visible = false;
     if ($gridType == "search") {
         $visible = $field->getVisibleSearch();
     } elseif ($gridType == "grid") {
         $visible = $field->getVisibleGridView();
     } elseif ($gridType == "all") {
         $visible = true;
     }
     if (!$field->getInvisible() && ($force || $visible)) {
         Object\Service::enrichLayoutDefinition($field);
         return array("key" => $key, "type" => $field->getFieldType(), "label" => $title, "config" => $config, "layout" => $field, "position" => $position);
     } else {
         return null;
     }
 }
开发者ID:cannonerd,项目名称:pimcore,代码行数:36,代码来源:ObjectHelperController.php

示例4: objectbrickListAction

 public function objectbrickListAction()
 {
     $list = new Object\Objectbrick\Definition\Listing();
     $list = $list->load();
     if ($this->hasParam("class_id") && $this->hasParam("field_name")) {
         $filteredList = [];
         $classId = $this->getParam("class_id");
         $fieldname = $this->getParam("field_name");
         foreach ($list as $type) {
             /** @var  $type Object\Objectbrick\Definition */
             $clsDefs = $type->getClassDefinitions();
             if (!empty($clsDefs)) {
                 foreach ($clsDefs as $cd) {
                     if ($cd["classname"] == $classId && $cd["fieldname"] == $fieldname) {
                         $filteredList[] = $type;
                         continue;
                     }
                 }
             }
             $layout = $type->getLayoutDefinitions();
             Object\Service::enrichLayoutDefinition($layout);
             $type->setLayoutDefinitions($layout);
         }
         $list = $filteredList;
     }
     $returnValueContainer = new Model\Tool\Admin\EventDataContainer($list);
     \Pimcore::getEventManager()->trigger("admin.class.objectbrickList.preSendData", $this, ["returnValueContainer" => $returnValueContainer, "objectId" => $this->getParam('object_id')]);
     $this->_helper->json(["objectbricks" => $list]);
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:29,代码来源:ClassController.php


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