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


PHP Document::getById方法代码示例

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


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

示例1: inotherlang

 /**
  * @param $document
  * @param null $language
  * @return Document|null
  */
 public function inotherlang($document, $language = null)
 {
     $documentInOtherLang = null;
     if (is_null($language)) {
         $language = CURRENT_LANGUAGE;
     }
     if ($document instanceof Document) {
         $id = $document->getId();
     } elseif (is_numeric($document)) {
         $id = $document;
     } else {
         $id = 0;
     }
     $otherLangId = null;
     try {
         if (class_exists('\\Multilingual\\Document')) {
             $otherLangId = \Multilingual\Document::getDocumentIdInOtherLanguage($id, $language);
         } else {
             $otherLangId = $id;
         }
     } catch (Exception $e) {
     }
     if ($otherLangId) {
         $documentInOtherLang = Document::getById($otherLangId);
     }
     return $documentInOtherLang;
 }
开发者ID:studioemma,项目名称:multilingual,代码行数:32,代码来源:inotherlang.php

示例2: importDocuments

 public function importDocuments()
 {
     $file = sprintf('%s/documents.json', $this->baseDir);
     $docs = new \Zend_Config_Json($file);
     foreach ($docs as $def) {
         $def = $def->toArray();
         $parent = Document::getByPath($def['parent']);
         unset($def['parent']);
         if (!$parent) {
             $parent = Document::getById(1);
         }
         $path = $parent->getFullPath() . '/' . $def['key'];
         if (Document\Service::pathExists($path)) {
             $doc = Document::getByPath($path);
         } else {
             $docClass = '\\Pimcore\\Model\\Document\\' . ucfirst($def['type']);
             /** @var Document $doc */
             $doc = $docClass::create($parent->getId(), $def, false);
             $doc->setUserOwner(self::getUser()->getId());
             $doc->setUserModification(self::getUser()->getId());
         }
         $doc->setValues($def);
         $doc->setPublished(true);
         $doc->save();
     }
 }
开发者ID:Pegasuz,项目名称:member,代码行数:26,代码来源:Installer.php

示例3: getSourceDocument

 /**
  * @return Document\PageSnippet
  */
 public function getSourceDocument()
 {
     if ($this->getSourceId()) {
         return Document::getById($this->getSourceId());
     }
     return null;
 }
开发者ID:sfie,项目名称:pimcore,代码行数:10,代码来源:Hardlink.php

示例4: codeAction

 public function codeAction()
 {
     $url = "";
     if ($this->getParam("name")) {
         $url = $this->getRequest()->getScheme() . "://" . $this->getRequest()->getHttpHost() . "/qr~-~code/" . $this->getParam("name");
     } elseif ($this->getParam("documentId")) {
         $doc = Document::getById($this->getParam("documentId"));
         $url = $this->getRequest()->getScheme() . "://" . $this->getRequest()->getHttpHost() . $doc->getFullPath();
     } elseif ($this->getParam("url")) {
         $url = $this->getParam("url");
     }
     $code = new \Endroid\QrCode\QrCode();
     $code->setText($url);
     $code->setPadding(0);
     $code->setSize(500);
     $hexToRGBA = function ($hex) {
         list($r, $g, $b) = sscanf($hex, "#%02x%02x%02x");
         return ["r" => $r, "g" => $g, "b" => $b, "a" => 0];
     };
     if (strlen($this->getParam("foreColor", "")) == 7) {
         $code->setForegroundColor($hexToRGBA($this->getParam("foreColor")));
     }
     if (strlen($this->getParam("backgroundColor", "")) == 7) {
         $code->setBackgroundColor($hexToRGBA($this->getParam("backgroundColor")));
     }
     header("Content-Type: image/png");
     if ($this->getParam("download")) {
         $code->setSize(4000);
         header('Content-Disposition: attachment;filename="qrcode-' . $this->getParam("name", "preview") . '.png"', true);
     }
     $code->render();
     exit;
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:33,代码来源:QrcodeController.php

示例5: load

 /**
  * Loads a list of entries for the specicifies parameters, returns an array of Search\Backend\Data
  *
  * @return array
  */
 public function load()
 {
     $entries = array();
     $data = $this->db->fetchAll("SELECT * FROM search_backend_data" . $this->getCondition() . $this->getGroupBy() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     foreach ($data as $entryData) {
         if ($entryData['maintype'] == 'document') {
             $element = Document::getById($entryData['id']);
         } else {
             if ($entryData['maintype'] == 'asset') {
                 $element = Asset::getById($entryData['id']);
             } else {
                 if ($entryData['maintype'] == 'object') {
                     $element = Object::getById($entryData['id']);
                 } else {
                     \Logger::err("unknown maintype ");
                 }
             }
         }
         if ($element) {
             $entry = new Search\Backend\Data();
             $entry->setId(new Search\Backend\Data\Id($element));
             $entry->setFullPath($entryData['fullpath']);
             $entry->setType($entryData['type']);
             $entry->setSubtype($entryData['subtype']);
             $entry->setUserOwner($entryData['userowner']);
             $entry->setUserModification($entryData['usermodification']);
             $entry->setCreationDate($entryData['creationdate']);
             $entry->setModificationDate($entryData['modificationdate']);
             $entry->setPublished($entryData['published'] === 0 ? false : true);
             $entries[] = $entry;
         }
     }
     $this->model->setEntries($entries);
     return $entries;
 }
开发者ID:sfie,项目名称:pimcore,代码行数:40,代码来源:Dao.php

示例6: _handleError

 /**
  * @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);
 }
开发者ID:solverat,项目名称:pimcore,代码行数:61,代码来源:ErrorHandler.php

示例7: ruleGetAction

 public function ruleGetAction()
 {
     $target = Targeting\Rule::getById($this->getParam("id"));
     $redirectUrl = $target->getActions()->getRedirectUrl();
     if (is_numeric($redirectUrl)) {
         $doc = Document::getById($redirectUrl);
         if ($doc instanceof Document) {
             $target->getActions()->redirectUrl = $doc->getFullPath();
         }
     }
     $this->_helper->json($target);
 }
开发者ID:solverat,项目名称:pimcore,代码行数:12,代码来源:TargetingController.php

示例8: load

 /**
  * Loads a list of objects (all are an instance of Document) for the given parameters an return them
  *
  * @return array
  */
 public function load()
 {
     $documents = array();
     $documentsData = $this->db->fetchAll("SELECT id,type FROM documents" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     foreach ($documentsData as $documentData) {
         if ($documentData["type"]) {
             if ($doc = Document::getById($documentData["id"])) {
                 $documents[] = $doc;
             }
         }
     }
     $this->model->setDocuments($documents);
     return $documents;
 }
开发者ID:sfie,项目名称:pimcore,代码行数:19,代码来源:Dao.php

示例9: load

 /**
  * Loads a list of objects (all are an instance of Document) for the given parameters an return them
  *
  * @return array
  */
 public function load()
 {
     $documents = [];
     $select = (string) $this->getQuery(['id', "type"]);
     $documentsData = $this->db->fetchAll($select, $this->model->getConditionVariables());
     foreach ($documentsData as $documentData) {
         if ($documentData["type"]) {
             if ($doc = Document::getById($documentData["id"])) {
                 $documents[] = $doc;
             }
         }
     }
     $this->model->setDocuments($documents);
     return $documents;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:20,代码来源:Dao.php

示例10: getTranslations

 /**
  * @param Document $document
  * @return array
  */
 public function getTranslations(Document $document)
 {
     $sourceId = $this->getTranslationSourceId($document);
     $data = $this->db->fetchAll("SELECT id,language FROM documents_translations WHERE sourceId = ?", [$sourceId]);
     $translations = [];
     foreach ($data as $translation) {
         $translations[$translation["language"]] = $translation["id"];
     }
     // add language from source document
     if (!empty($translations)) {
         $sourceDocument = Document::getById($sourceId);
         $translations[$sourceDocument->getProperty("language")] = $sourceDocument->getId();
     }
     return $translations;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:19,代码来源:Dao.php

示例11: treeGetChildsByIdAction

 /**
  * Original function
  * @see Admin_DocumentController::treeGetChildsByIdAction()
  */
 public function treeGetChildsByIdAction()
 {
     $languages = Tool::getValidLanguages();
     $language = $this->_getParam("language", reset($languages));
     $document = Document::getById($this->getParam("node"));
     $documents = array();
     if ($document->hasChilds()) {
         $limit = intval($this->getParam("limit"));
         if (!$this->getParam("limit")) {
             $limit = 100000000;
         }
         $offset = intval($this->getParam("start"));
         $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\r\n                                        (\r\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\r\n                                        or\r\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\r\n                                        )", $document->getId());
         }
         $list->setOrderKey("index");
         $list->setOrder("asc");
         $list->setLimit($limit);
         $list->setOffset($offset);
         $childsList = $list->load();
         foreach ($childsList as $childDocument) {
             // only display document if listing is allowed for the current user
             if ($childDocument->isAllowed("list")) {
                 if ($childDocument instanceof Document\Page && $childDocument->hasProperty('isLanguageRoot') && $childDocument->getProperty('isLanguageRoot') == 1) {
                     if ($childDocument->getKey() == $language) {
                         //                            $documents[] = $this->getTreeNodeConfig($childDocument);
                         $config = $this->getTreeNodeConfig($childDocument);
                         $config['expanded'] = true;
                         $documents[] = $config;
                     }
                 } else {
                     $documents[] = $this->getTreeNodeConfig($childDocument);
                 }
             }
         }
     }
     if ($this->getParam("limit")) {
         $this->_helper->json(array("offset" => $offset, "limit" => $limit, "total" => $document->getChildAmount($this->getUser()), "nodes" => $documents));
     } else {
         $this->_helper->json($documents);
     }
     $this->_helper->json(false);
 }
开发者ID:studioemma,项目名称:multilingual,代码行数:52,代码来源:IndexController.php

示例12: getFilterPath

 protected function getFilterPath()
 {
     if ($this->getParam("type") == "document" && $this->getParam("id")) {
         $doc = Document::getById($this->getParam("id"));
         $path = $doc->getFullPath();
         if ($doc instanceof Document\Page && $doc->getPrettyUrl()) {
             $path = $doc->getPrettyUrl();
         }
         if ($this->getParam("site")) {
             $site = Site::getById($this->getParam("site"));
             $path = preg_replace("@^" . preg_quote($site->getRootPath(), "@") . "/@", "/", $path);
         }
         return $path;
     }
     return $this->getParam("path");
 }
开发者ID:solverat,项目名称:pimcore,代码行数:16,代码来源:AnalyticsController.php

示例13: testAction

 public function testAction()
 {
     /*
      * This is an example of a categorization of controllers
      * you can create folders to structure your controllers into sub-modules
      *
      * The controller name is then the name of the folder and the controller, separated by an underscore (_)
      * in this case this is "category_example"
      *
      * For this example there's a static route and a document defined
      * Name of static route: "category-example"
      * Path of document: /en/advanced-examples/sub-modules
      */
     $this->enableLayout();
     // this is needed so that the layout can be rendered
     $this->setDocument(\Pimcore\Model\Document::getById(1));
 }
开发者ID:solverat,项目名称:pimcore,代码行数:17,代码来源:ExampleController.php

示例14: preDispatch

 public function preDispatch()
 {
     parent::preDispatch();
     if ($this->getParam('ctype') === 'document') {
         $this->element = Document::getById((int) $this->getParam('cid', 0));
     } elseif ($this->getParam('ctype') === 'asset') {
         $this->element = Asset::getById((int) $this->getParam('cid', 0));
     } elseif ($this->getParam('ctype') === 'object') {
         $this->element = ConcreteObject::getById((int) $this->getParam('cid', 0));
     }
     if (!$this->element) {
         throw new \Exception('Cannot load element' . $this->getParam('cid') . ' of type \'' . $this->getParam('ctype') . '\'');
     }
     //get the latest available version of the element -
     //$this->element = $this->getLatestVersion($this->element);
     $this->element->setUserModification($this->getUser()->getId());
 }
开发者ID:solverat,项目名称:pimcore,代码行数:17,代码来源:WorkflowController.php

示例15: getDocumentInOtherLanguage

 /**
  * @param $sourceDocument
  * @param $intendedLanguage
  * @return bool|\Pimcore\Model\Document
  */
 public static function getDocumentInOtherLanguage($sourceDocument, $intendedLanguage)
 {
     if ($sourceDocument instanceof \Pimcore\Model\Document) {
         $documentId = $sourceDocument->getId();
     } else {
         $documentId = $sourceDocument;
     }
     $tSource = new Keys();
     $tTarget = new Keys();
     $select = $tSource->select()->from(array("s" => $tSource->info("name")), array())->from(array("t" => $tTarget->info("name")), array("document_id"))->where("s.document_id = ?", $documentId)->where("s.sourcePath = t.sourcePath")->where("t.language = ?", $intendedLanguage);
     $row = $tSource->fetchRow($select);
     if (!empty($row)) {
         return \Pimcore\Model\Document::getById($row->document_id);
     } else {
         return false;
     }
 }
开发者ID:studioemma,项目名称:multilingual,代码行数:22,代码来源:Document.php


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