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


PHP Element\Service类代码示例

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


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

示例1: getDataByIdAction

 public function getDataByIdAction()
 {
     // check for lock
     if (Element\Editlock::isLocked($this->getParam("id"), "document")) {
         $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "document")));
     }
     Element\Editlock::lock($this->getParam("id"), "document");
     $page = Document\Page::getById($this->getParam("id"));
     $page = $this->getLatestVersion($page);
     $page->setVersions(array_splice($page->getVersions(), 0, 1));
     $page->getScheduledTasks();
     $page->idPath = Element\Service::getIdPath($page);
     $page->userPermissions = $page->getUserPermissions();
     $page->setLocked($page->isLocked());
     $page->setParent(null);
     if ($page->getContentMasterDocument()) {
         $page->contentMasterDocumentPath = $page->getContentMasterDocument()->getRealFullPath();
     }
     // get depending redirects
     $redirectList = new Redirect\Listing();
     $redirectList->setCondition("target = ?", $page->getId());
     $page->redirects = $redirectList->load();
     // unset useless data
     $page->setElements(null);
     $page->childs = null;
     // cleanup properties
     $this->minimizeProperties($page);
     if ($page->isAllowed("view")) {
         $this->_helper->json($page);
     }
     $this->_helper->json(false);
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:32,代码来源:PageController.php

示例2: getDataByIdAction

 public function getDataByIdAction()
 {
     // check for lock
     if (Element\Editlock::isLocked($this->getParam("id"), "document")) {
         $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "document")));
     }
     Element\Editlock::lock($this->getParam("id"), "document");
     $snippet = Document\Snippet::getById($this->getParam("id"));
     $modificationDate = $snippet->getModificationDate();
     $snippet = $this->getLatestVersion($snippet);
     $snippet->setVersions(array_splice($snippet->getVersions(), 0, 1));
     $snippet->getScheduledTasks();
     $snippet->idPath = Element\Service::getIdPath($snippet);
     $snippet->userPermissions = $snippet->getUserPermissions();
     $snippet->setLocked($snippet->isLocked());
     $snippet->setParent(null);
     if ($snippet->getContentMasterDocument()) {
         $snippet->contentMasterDocumentPath = $snippet->getContentMasterDocument()->getRealFullPath();
     }
     $this->minimizeProperties($snippet);
     // unset useless data
     $snippet->setElements(null);
     if ($snippet->isAllowed("view")) {
         $this->_helper->json($snippet);
     }
     $this->_helper->json(false);
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:27,代码来源:SnippetController.php

示例3: 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");
     $link = Document\Hardlink::getById($this->getParam("id"));
     $link = clone $link;
     $link->idPath = Element\Service::getIdPath($link);
     $link->userPermissions = $link->getUserPermissions();
     $link->setLocked($link->isLocked());
     $link->setParent(null);
     if ($link->getSourceDocument()) {
         $link->sourcePath = $link->getSourceDocument()->getRealFullPath();
     }
     $this->addTranslationsData($link);
     $this->minimizeProperties($link);
     //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($link));
     \Pimcore::getEventManager()->trigger("admin.document.get.preSendData", $this, ["document" => $link, "returnValueContainer" => $returnValueContainer]);
     if ($link->isAllowed("view")) {
         $this->_helper->json($returnValueContainer->getData());
     }
     $this->_helper->json(false);
 }
开发者ID:solverat,项目名称:pimcore,代码行数:27,代码来源:HardlinkController.php

示例4: extractRelations

 public function extractRelations($element, $apiElementKeys, $recursive, $includeRelations)
 {
     $foundRelations = [];
     if ($includeRelations) {
         $dependency = $element->getDependencies();
         if ($dependency) {
             foreach ($dependency->getRequires() as $r) {
                 if ($e = Element\Service::getDependedElement($r)) {
                     if ($element->getId() != $e->getId() and !in_array(Element\Service::getElementType($e) . "_" . $e->getId(), $apiElementKeys)) {
                         $foundRelations[Element\Service::getElementType($e) . "_" . $e->getId()] = ["elementType" => Element\Service::getType($e), "element" => $e->getId(), "recursive" => false];
                     }
                 }
             }
         }
     }
     $childs = $element->getChilds();
     if ($recursive and $childs) {
         foreach ($childs as $child) {
             if (!in_array(Element\Service::getType($child) . "_" . $child->getId(), $apiElementKeys)) {
                 $foundRelations[Element\Service::getType($child) . "_" . $child->getId()] = ["elementType" => Element\Service::getType($child), "element" => $child->getId(), "recursive" => $recursive];
             }
         }
     }
     return $foundRelations;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:25,代码来源:Service.php

示例5: 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

示例6: getDataByIdAction

 public function getDataByIdAction()
 {
     // check for lock
     if (\Pimcore\Model\Element\Editlock::isLocked($this->getParam("id"), "document")) {
         $this->_helper->json(["editlock" => \Pimcore\Model\Element\Editlock::getByElement($this->getParam("id"), "document")]);
     }
     \Pimcore\Model\Element\Editlock::lock($this->getParam("id"), "document");
     $page = Document\Printpage::getById($this->getParam("id"));
     $page = $this->getLatestVersion($page);
     $page->getVersions();
     $page->getScheduledTasks();
     $page->idPath = Service::getIdPath($page);
     $page->userPermissions = $page->getUserPermissions();
     $page->setLocked($page->isLocked());
     if ($page->getContentMasterDocument()) {
         $page->contentMasterDocumentPath = $page->getContentMasterDocument()->getRealFullPath();
     }
     $this->addTranslationsData($page);
     // unset useless data
     $page->setElements(null);
     $page->childs = null;
     // cleanup properties
     $this->minimizeProperties($page);
     //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($page));
     \Pimcore::getEventManager()->trigger("admin.document.get.preSendData", $this, ["document" => $page, "returnValueContainer" => $returnValueContainer]);
     if ($page->isAllowed("view")) {
         $this->_helper->json($returnValueContainer->getData());
     }
     $this->_helper->json(false);
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:32,代码来源:Printpage.php

示例7: __construct

 /**
  * @param $webResource
  */
 public function __construct($webResource)
 {
     $this->id = $webResource->getId();
     if ($webResource instanceof Element\ElementInterface) {
         $this->type = Element\Service::getType($webResource);
     } else {
         $this->type = "unknown";
     }
 }
开发者ID:Gerhard13,项目名称:pimcore,代码行数:12,代码来源:Id.php

示例8: getElementWorkflowConfig

 /**
  * gets workflow config for element. always returns first valid workflow config
  *
  * @param Asset|Document|ConcreteObject $element
  * @return array
  */
 public static function getElementWorkflowConfig(AbstractElement $element)
 {
     $config = self::getWorkflowManagementConfig();
     if (!is_array($config)) {
         return null;
     }
     $elementType = Service::getElementType($element);
     $elementSubType = $element->getType();
     foreach ($config['workflows'] as $workflow) {
         //workflow is not enabled, continue with next
         if (isset($workflow['enabled']) && !$workflow['enabled']) {
             continue;
         }
         if (isset($workflow['workflowSubject']) && in_array($elementType, $workflow['workflowSubject']['types'])) {
             switch ($elementType) {
                 case 'asset':
                     if (isset($workflow['workflowSubject']['assetTypes']) && is_array($workflow['workflowSubject']['assetTypes'])) {
                         if (in_array($elementSubType, $workflow['workflowSubject']['assetTypes'])) {
                             return $workflow;
                         }
                     } else {
                         \Logger::warning('WorkflowManagement::getClassWorkflowConfig workflow does not feature a valid array of available asset types');
                     }
                     break;
                 case 'document':
                     if (isset($workflow['workflowSubject']['documentTypes']) && is_array($workflow['workflowSubject']['documentTypes'])) {
                         if (in_array($elementSubType, $workflow['workflowSubject']['documentTypes'])) {
                             return $workflow;
                         }
                     } else {
                         \Logger::warning('WorkflowManagement::getClassWorkflowConfig workflow does not feature a valid array of available document types');
                     }
                     break;
                 case 'object':
                     if ($element instanceof ConcreteObject) {
                         if (isset($workflow['workflowSubject']['classes']) && is_array($workflow['workflowSubject']['classes'])) {
                             $classId = $element->getClassId();
                             if (in_array($classId, $workflow['workflowSubject']['classes'])) {
                                 return $workflow;
                             }
                         } else {
                             \Logger::warning('WorkflowManagement::getClassWorkflowConfig workflow does not feature a valid array of available class ID\'s');
                         }
                     }
                     break;
                 default:
                     //unknown element type, return null
                     return null;
             }
         }
     }
     return null;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:59,代码来源:Config.php

示例9: setName

 /**
  * @param string $name
  * @return $this|void
  * @throws DAV\Exception\Forbidden
  * @throws \Exception
  */
 public function setName($name)
 {
     if ($this->asset->isAllowed("rename")) {
         $user = AdminTool::getCurrentUser();
         $this->asset->setUserModification($user->getId());
         $this->asset->setFilename(Element\Service::getValidKey($name), "asset");
         $this->asset->save();
     } else {
         throw new DAV\Exception\Forbidden();
     }
     return $this;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:18,代码来源:File.php

示例10: getByElement

 /**
  * @param $cid
  * @param $ctype
  * @throws \Exception
  */
 public function getByElement($cid, $ctype)
 {
     $data = $this->db->fetchRow("SELECT * FROM edit_lock WHERE cid = ? AND ctype = ?", array($cid, $ctype));
     if (!$data["id"]) {
         throw new \Exception("Lock with cid " . $cid . " and ctype " . $ctype . " not found");
     }
     $this->assignVariablesToModel($data);
     // add elements path
     $element = Model\Element\Service::getElementById($ctype, $cid);
     if ($element) {
         $this->model->setCpath($element->getFullpath());
     }
 }
开发者ID:rolandstoll,项目名称:pimcore,代码行数:18,代码来源:Resource.php

示例11: interpret

 public static function interpret($value, $config = null)
 {
     $result = array();
     if (is_array($value)) {
         foreach ($value as $v) {
             $result[] = array("dest" => $v->getId(), "type" => \Pimcore\Model\Element\Service::getElementType($v));
         }
     } else {
         if ($value instanceof \Pimcore\Model\Element\AbstractElement) {
             $result[] = array("dest" => $value->getId(), "type" => \Pimcore\Model\Element\Service::getElementType($value));
         }
     }
     return $result;
 }
开发者ID:ascertain,项目名称:NGshop,代码行数:14,代码来源:DefaultRelations.php

示例12: getWebsiteConfig

 /**
  * @static
  * @return mixed|\Zend_Config
  */
 public static function getWebsiteConfig()
 {
     if (\Zend_Registry::isRegistered("pimcore_config_website")) {
         $config = \Zend_Registry::get("pimcore_config_website");
     } else {
         $cacheKey = "website_config";
         $siteId = null;
         if (Model\Site::isSiteRequest()) {
             $siteId = Model\Site::getCurrentSite()->getId();
             $cacheKey = $cacheKey . "_site_" . $siteId;
         }
         if (!($config = Cache::load($cacheKey))) {
             $settingsArray = array();
             $cacheTags = array("website_config", "system", "config", "output");
             $list = new Model\WebsiteSetting\Listing();
             $list = $list->load();
             foreach ($list as $item) {
                 $key = $item->getName();
                 $itemSiteId = $item->getSiteId();
                 if ($itemSiteId != 0 && $itemSiteId != $siteId) {
                     continue;
                 }
                 $s = null;
                 switch ($item->getType()) {
                     case "document":
                     case "asset":
                     case "object":
                         $s = Model\Element\Service::getElementById($item->getType(), $item->getData());
                         break;
                     case "bool":
                         $s = (bool) $item->getData();
                         break;
                     case "text":
                         $s = (string) $item->getData();
                         break;
                 }
                 if ($s instanceof Model\Element\ElementInterface) {
                     $cacheTags = $s->getCacheTags($cacheTags);
                 }
                 if (isset($s)) {
                     $settingsArray[$key] = $s;
                 }
             }
             $config = new \Zend_Config($settingsArray, true);
             Cache::save($config, $cacheKey, $cacheTags, null, 998);
         }
         self::setWebsiteConfig($config);
     }
     return $config;
 }
开发者ID:pawansgi92,项目名称:pimcore2,代码行数:54,代码来源:Config.php

示例13: getDataByIdAction

 public function getDataByIdAction()
 {
     // check for lock
     if (Element\Editlock::isLocked($this->getParam("id"), "document")) {
         $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "document")));
     }
     Element\Editlock::lock($this->getParam("id"), "document");
     $folder = Document\Folder::getById($this->getParam("id"));
     $folder->idPath = Element\Service::getIdPath($folder);
     $folder->userPermissions = $folder->getUserPermissions();
     $folder->setLocked($folder->isLocked());
     $folder->setParent(null);
     $this->minimizeProperties($folder);
     if ($folder->isAllowed("view")) {
         $this->_helper->json($folder);
     }
     $this->_helper->json(false);
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:18,代码来源:FolderController.php

示例14: move

 /**
  * Moves a file/directory
  *
  * @param string $sourcePath
  * @param string $destinationPath
  * @return void
  */
 public function move($sourcePath, $destinationPath)
 {
     $nameParts = explode("/", $sourcePath);
     $nameParts[count($nameParts) - 1] = Element\Service::getValidKey($nameParts[count($nameParts) - 1], "asset");
     $sourcePath = implode("/", $nameParts);
     $nameParts = explode("/", $destinationPath);
     $nameParts[count($nameParts) - 1] = Element\Service::getValidKey($nameParts[count($nameParts) - 1], "asset");
     $destinationPath = implode("/", $nameParts);
     try {
         if (dirname($sourcePath) == dirname($destinationPath)) {
             $asset = null;
             if ($asset = Asset::getByPath("/" . $destinationPath)) {
                 // If we got here, this means the destination exists, and needs to be overwritten
                 $sourceAsset = Asset::getByPath("/" . $sourcePath);
                 $asset->setData($sourceAsset->getData());
                 $sourceAsset->delete();
             }
             // see: Asset\WebDAV\File::delete() why this is necessary
             $log = Asset\WebDAV\Service::getDeleteLog();
             if (!$asset && array_key_exists("/" . $destinationPath, $log)) {
                 $asset = \Pimcore\Tool\Serialize::unserialize($log["/" . $destinationPath]["data"]);
                 if ($asset) {
                     $sourceAsset = Asset::getByPath("/" . $sourcePath);
                     $asset->setData($sourceAsset->getData());
                     $sourceAsset->delete();
                 }
             }
             if (!$asset) {
                 $asset = Asset::getByPath("/" . $sourcePath);
             }
             $asset->setFilename(basename($destinationPath));
         } else {
             $asset = Asset::getByPath("/" . $sourcePath);
             $parent = Asset::getByPath("/" . dirname($destinationPath));
             $asset->setPath($parent->getRealFullPath() . "/");
             $asset->setParentId($parent->getId());
         }
         $user = \Pimcore\Tool\Admin::getCurrentUser();
         $asset->setUserModification($user->getId());
         $asset->save();
     } catch (\Exception $e) {
         Logger::error($e);
     }
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:51,代码来源:Tree.php

示例15: treeGetChildsByIdAction

 public function treeGetChildsByIdAction()
 {
     $document = Document::getById($this->getParam("node"));
     $documents = [];
     $cv = false;
     if ($document->hasChilds()) {
         $limit = intval($this->getParam("limit"));
         if (!$this->getParam("limit")) {
             $limit = 100000000;
         }
         $offset = intval($this->getParam("start"));
         if ($this->getParam("view")) {
             $cv = \Pimcore\Model\Element\Service::getCustomViewById($this->getParam("view"));
         }
         $list = new Document\Listing();
         if ($this->getUser()->isAdmin()) {
             $list->setCondition("parentId = ? ", $document->getId());
         } else {
             $userIds = $this->getUser()->getRoles();
             $userIds[] = $this->getUser()->getId();
             $list->setCondition("parentId = ? and\n                                        (\n                                        (select list from users_workspaces_document where userId in (" . implode(',', $userIds) . ") and LOCATE(CONCAT(path,`key`),cpath)=1  ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n                                        or\n                                        (select list from users_workspaces_document where userId in (" . implode(',', $userIds) . ") and LOCATE(cpath,CONCAT(path,`key`))=1  ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n                                        )", $document->getId());
         }
         $list->setOrderKey(["index", "id"]);
         $list->setOrder(["asc", "asc"]);
         $list->setLimit($limit);
         $list->setOffset($offset);
         \Pimcore\Model\Element\Service::addTreeFilterJoins($cv, $list);
         $childsList = $list->load();
         foreach ($childsList as $childDocument) {
             // only display document if listing is allowed for the current user
             if ($childDocument->isAllowed("list")) {
                 $documents[] = $this->getTreeNodeConfig($childDocument);
             }
         }
     }
     if ($this->getParam("limit")) {
         $this->_helper->json(["offset" => $offset, "limit" => $limit, "total" => $document->getChildAmount($this->getUser()), "nodes" => $documents]);
     } else {
         $this->_helper->json($documents);
     }
     $this->_helper->json(false);
 }
开发者ID:solverat,项目名称:pimcore,代码行数:42,代码来源:DocumentController.php


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