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


PHP Document::getByPath方法代码示例

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


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

示例1: setValuesToDocument

 protected function setValuesToDocument(Document\Link $link)
 {
     // data
     if ($this->getParam("data")) {
         $data = \Zend_Json::decode($this->getParam("data"));
         if (!empty($data["path"])) {
             if ($document = Document::getByPath($data["path"])) {
                 $data["linktype"] = "internal";
                 $data["internalType"] = "document";
                 $data["internal"] = $document->getId();
             } elseif ($asset = Asset::getByPath($data["path"])) {
                 $data["linktype"] = "internal";
                 $data["internalType"] = "asset";
                 $data["internal"] = $asset->getId();
             } else {
                 $data["linktype"] = "direct";
                 $data["direct"] = $data["path"];
             }
         } else {
             // clear content of link
             $data["linktype"] = "internal";
             $data["direct"] = "";
             $data["internalType"] = null;
             $data["internal"] = null;
         }
         unset($data["path"]);
         $link->setValues($data);
     }
     $this->addPropertiesToDocument($link);
 }
开发者ID:solverat,项目名称:pimcore,代码行数:30,代码来源:LinkController.php

示例2: subscribeAction

 public function subscribeAction()
 {
     $this->enableLayout();
     $newsletter = new Newsletter("person");
     // replace "crm" with the class name you have used for your class above (mailing list)
     $params = $this->getAllParams();
     $this->view->success = false;
     if ($newsletter->checkParams($params)) {
         try {
             $params["parentId"] = 1;
             // default folder (home) where we want to save our subscribers
             $newsletterFolder = Model\Object::getByPath("/crm/newsletter");
             if ($newsletterFolder) {
                 $params["parentId"] = $newsletterFolder->getId();
             }
             $user = $newsletter->subscribe($params);
             // user and email document
             // parameters available in the email: gender, firstname, lastname, email, token, object
             // ==> see mailing framework
             $newsletter->sendConfirmationMail($user, Model\Document::getByPath("/en/advanced-examples/newsletter/confirmation-email"), ["additional" => "parameters"]);
             // do some other stuff with the new user
             $user->setDateRegister(new \DateTime());
             $user->save();
             $this->view->success = true;
         } catch (\Exception $e) {
             echo $e->getMessage();
         }
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:29,代码来源:NewsletterController.php

示例3: addLanguage

 public function addLanguage($languageToAdd)
 {
     // Check if language is not already added
     if (in_array($languageToAdd, Tool::getValidLanguages())) {
         $result = false;
     } else {
         // Read all the documents from the first language
         $availableLanguages = Tool::getValidLanguages();
         $firstLanguageDocument = \Pimcore\Model\Document::getByPath('/' . reset($availableLanguages));
         \Zend_Registry::set('SEI18N_add', 1);
         // Add the language main folder
         $document = Page::create(1, array('key' => $languageToAdd, "userOwner" => 1, "userModification" => 1, "published" => true, "controller" => 'default', "action" => 'go-to-first-child'));
         $document->setProperty('language', 'text', $languageToAdd);
         // Set the language to this folder and let it inherit to the child pages
         $document->setProperty('isLanguageRoot', 'text', 1, false, false);
         // Set as language root document
         $document->save();
         // Add Link to other languages
         $t = new Keys();
         $t->insert(array("document_id" => $document->getId(), "language" => $languageToAdd, "sourcePath" => $firstLanguageDocument->getFullPath()));
         // Lets add all the docs
         $this->addDocuments($firstLanguageDocument->getId(), $languageToAdd);
         \Zend_Registry::set('SEI18N_add', 0);
         $oldConfig = Config::getSystemConfig();
         $settings = $oldConfig->toArray();
         $languages = explode(',', $settings['general']['validLanguages']);
         $languages[] = $languageToAdd;
         $settings['general']['validLanguages'] = implode(',', $languages);
         $config = new \Zend_Config($settings, true);
         $writer = new \Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_SYSTEM));
         $writer->write();
         $result = true;
     }
     return $result;
 }
开发者ID:studioemma,项目名称:multilingual,代码行数:35,代码来源:Document.php

示例4: setDataFromEditmode

 /**
  * @see Document\Tag\TagInterface::setDataFromEditmode
  * @param mixed $data
  * @return void
  */
 public function setDataFromEditmode($data)
 {
     if (!is_array($data)) {
         $data = array();
     }
     if ($doc = Document::getByPath($data['path'])) {
         if ($doc instanceof Document) {
             $data['internal'] = true;
             $data['internalId'] = $doc->getId();
             $data['internalType'] = 'document';
         }
         //its an object?
     } else {
         if (strpos($data['path'], '::') !== FALSE) {
             $data['internal'] = true;
             $data['internalType'] = 'object';
         }
     }
     if (!$data['internal']) {
         if ($asset = Asset::getByPath($data['path'])) {
             if ($asset instanceof Asset) {
                 $data['internal'] = true;
                 $data['internalId'] = $asset->getId();
                 $data['internalType'] = 'asset';
             }
         }
     }
     $this->data = $data;
     return $this;
 }
开发者ID:dachcom-digital,项目名称:pimcore-toolbox,代码行数:35,代码来源:Globallink.php

示例5: sendEmail

 /**
  * @param object $participation
  * @return void
  * @throws \Exception
  */
 public function sendEmail($participation)
 {
     $email = $participation->getEmail();
     $emailDomain = trim(strtolower(preg_replace('/^[^@]+@/', '', $email)));
     $participation->setEmailDomain($emailDomain);
     $participation->save();
     $confirmationLink = $this->createConfirmationLink($participation->getConfirmationCode());
     $parameters = array('confirmationLink' => $confirmationLink, 'participationId' => $participation->getId());
     $emailDocumentPath = Plugin::getConfig()->get('emailDocumentPath');
     $emailDocument = DocumentModel::getByPath($emailDocumentPath);
     if (!$emailDocument instanceof EmailDocument) {
         throw new \Exception("Error: emailDocumentPath [{$emailDocumentPath}] " . "is not a valid email document.");
     }
     $mail = new Mail();
     $mail->addTo($email);
     if ($this->getSubject()) {
         $mail->setSubject($this->getSubject());
     }
     $mail->setDocument($emailDocumentPath);
     $mail->setParams($parameters);
     $mail->send();
     $note = new Note();
     $note->setElement($participation);
     $note->setDate(time());
     $note->setType("confirmation");
     $note->setTitle("Email sent");
     $note->addData("email", "text", $email);
     $note->setUser(0);
     $note->save();
 }
开发者ID:basilicom,项目名称:pimcore-plugin-participation,代码行数:35,代码来源:Confirmation.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: setValuesToDocument

 protected function setValuesToDocument(Document\Hardlink $link)
 {
     // data
     $data = \Zend_Json::decode($this->getParam("data"));
     $sourceId = null;
     if ($sourceDocument = Document::getByPath($data["sourcePath"])) {
         $sourceId = $sourceDocument->getId();
     }
     $link->setSourceId($sourceId);
     $link->setValues($data);
     $this->addPropertiesToDocument($link);
 }
开发者ID:Gerhard13,项目名称:pimcore,代码行数:12,代码来源:HardlinkController.php

示例8: getErrorDocument

 private function getErrorDocument()
 {
     $config = Config::getSystemConfig();
     $errorDocPath = $config->documents->error_pages->default;
     if (Site::isSiteRequest()) {
         $site = Site::getCurrentSite();
         $errorDocPath = $site->getErrorDocument();
     }
     $errorDoc = Document::getByPath($errorDocPath);
     \Zend_Registry::set("pimcore_error_document", $errorDoc);
     return $errorDoc;
 }
开发者ID:shanky0110,项目名称:pimcore-plugin-subdomain-admin,代码行数:12,代码来源:FrontControllerPlugin.php

示例9: updateAction

 public function updateAction()
 {
     $letter = Newsletter\Config::getByName($this->getParam("name"));
     $data = \Zend_Json::decode($this->getParam("configuration"));
     if ($emailDoc = Document::getByPath($data["document"])) {
         $data["document"] = $emailDoc->getId();
     }
     foreach ($data as $key => $value) {
         $setter = "set" . ucfirst($key);
         if (method_exists($letter, $setter)) {
             $letter->{$setter}($value);
         }
     }
     $letter->save();
     $this->_helper->json(["success" => true]);
 }
开发者ID:solverat,项目名称:pimcore,代码行数:16,代码来源:NewsletterController.php

示例10: readGoogleResponse

 /**
  * @param $googleResponse
  */
 public function readGoogleResponse($googleResponse)
 {
     $googleResponse = $googleResponse["modelData"];
     $this->setRaw($googleResponse);
     // available factes
     if (array_key_exists("context", $googleResponse) && is_array($googleResponse["context"])) {
         if (array_key_exists("facets", $googleResponse["context"]) && is_array($googleResponse["context"]["facets"])) {
             $facets = array();
             foreach ($googleResponse["context"]["facets"] as $facet) {
                 $facets[$facet[0]["label"]] = $facet[0]["anchor"];
             }
             $this->setFacets($facets);
         }
     }
     // results incl. promotions, search results, ...
     $items = array();
     // set promotions
     if (array_key_exists("promotions", $googleResponse) && is_array($googleResponse["promotions"])) {
         foreach ($googleResponse["promotions"] as $promo) {
             $promo["type"] = "promotion";
             $promo["formattedUrl"] = preg_replace("@^https?://@", "", $promo["link"]);
             $promo["htmlFormattedUrl"] = $promo["formattedUrl"];
             $items[] = new Item($promo);
         }
     }
     // set search results
     $total = intval($googleResponse["searchInformation"]["totalResults"]);
     if ($total > 100) {
         $total = 100;
     }
     $this->setTotal($total);
     if (array_key_exists("items", $googleResponse) && is_array($googleResponse["items"])) {
         foreach ($googleResponse["items"] as $item) {
             // check for relation to document or asset
             // first check for an image
             if (array_key_exists("pagemap", $item) && is_array($item["pagemap"])) {
                 if (array_key_exists("cse_image", $item["pagemap"]) && is_array($item["pagemap"]["cse_image"])) {
                     if ($item["pagemap"]["cse_image"][0]) {
                         // try to get the asset id
                         if (preg_match("/thumb_([0-9]+)__/", $item["pagemap"]["cse_image"][0]["src"], $matches)) {
                             $test = $matches;
                             if ($matches[1]) {
                                 if ($image = Model\Asset::getById($matches[1])) {
                                     if ($image instanceof Model\Asset\Image) {
                                         $item["image"] = $image;
                                     }
                                 }
                             }
                         }
                         if (!array_key_exists("image", $item)) {
                             $item["image"] = $item["pagemap"]["cse_image"][0]["src"];
                         }
                     }
                 }
             }
             // now a document
             $urlParts = parse_url($item["link"]);
             if ($document = Model\Document::getByPath($urlParts["path"])) {
                 $item["document"] = $document;
             }
             $item["type"] = "searchresult";
             $items[] = new Item($item);
         }
     }
     $this->setResults($items);
 }
开发者ID:sfie,项目名称:pimcore,代码行数:69,代码来源:Cse.php

示例11: getNearestChildByPath

 /**
  * @param Document\Hardlink $hardlink
  * @param $path
  * @return Document
  */
 public static function getNearestChildByPath(Document\Hardlink $hardlink, $path)
 {
     if ($hardlink->getChildsFromSource() && $hardlink->getSourceDocument()) {
         $hardlinkRealPath = preg_replace("@^" . preg_quote($hardlink->getRealFullPath()) . "@", $hardlink->getSourceDocument()->getRealFullPath(), $path);
         $pathes = array();
         $pathes[] = "/";
         $pathParts = explode("/", $hardlinkRealPath);
         $tmpPathes = array();
         foreach ($pathParts as $pathPart) {
             $tmpPathes[] = $pathPart;
             $t = implode("/", $tmpPathes);
             if (!empty($t)) {
                 $pathes[] = $t;
             }
         }
         $pathes = array_reverse($pathes);
         foreach ($pathes as $p) {
             $hardLinkedDocument = Document::getByPath($p);
             if ($hardLinkedDocument instanceof Document) {
                 $hardLinkedDocument = self::wrap($hardLinkedDocument);
                 $hardLinkedDocument->setHardLinkSource($hardlink);
                 $_path = $path != "/" ? $_path = dirname($p) : $p;
                 $_path = str_replace("\\", "/", $_path);
                 // windows patch
                 $_path .= $_path != "/" ? "/" : "";
                 $_path = preg_replace("@^" . preg_quote($hardlink->getSourceDocument()->getRealPath()) . "@", $hardlink->getRealPath(), $_path);
                 $hardLinkedDocument->setPath($_path);
                 return $hardLinkedDocument;
             }
         }
     }
 }
开发者ID:rolandstoll,项目名称:pimcore,代码行数:37,代码来源:Service.php

示例12: removeDocuments

 public function removeDocuments()
 {
     $file = sprintf('%s/documents.json', $this->baseDir);
     $docs = new \Zend_Config_Json($file);
     $root = reset($docs->toArray());
     $doc = Document::getByPath('/' . ltrim($root['parent'] . '/' . $root['key'], '/'));
     if ($doc) {
         $doc->delete();
     }
 }
开发者ID:Pegasuz,项目名称:member,代码行数:10,代码来源:Installer.php

示例13: correctPath

 /**
  * @throws \Exception
  */
 public function correctPath()
 {
     // set path
     if ($this->getId() != 1) {
         // not for the root node
         if ($this->getParentId() == $this->getId()) {
             throw new \Exception("ParentID and ID is identical, an element can't be the parent of itself.");
         }
         $parent = Document::getById($this->getParentId());
         if ($parent) {
             // use the parent's path from the database here (getCurrentFullPath), to ensure the path really exists and does not rely on the path
             // that is currently in the parent object (in memory), because this might have changed but wasn't not saved
             $this->setPath(str_replace("//", "/", $parent->getCurrentFullPath() . "/"));
         } else {
             // parent document doesn't exist anymore, set the parent to to root
             $this->setParentId(1);
             $this->setPath("/");
         }
         if (strlen($this->getKey()) < 1) {
             $this->setKey("---no-valid-key---" . $this->getId());
             throw new \Exception("Document requires key, generated key automatically");
         }
     } else {
         if ($this->getId() == 1) {
             // some data in root node should always be the same
             $this->setParentId(0);
             $this->setPath("/");
             $this->setKey("");
             $this->setType("page");
         }
     }
     if (Document\Service::pathExists($this->getRealFullPath())) {
         $duplicate = Document::getByPath($this->getRealFullPath());
         if ($duplicate instanceof Document and $duplicate->getId() != $this->getId()) {
             throw new \Exception("Duplicate full path [ " . $this->getRealFullPath() . " ] - cannot save document");
         }
     }
     if (strlen($this->getRealFullPath()) > 765) {
         throw new \Exception("Full path is limited to 765 characters, reduce the length of your parent's path");
     }
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:44,代码来源:Document.php

示例14: setDataFromEditmode

 /**
  * @see Document\Tag\TagInterface::setDataFromEditmode
  * @param mixed $data
  * @return void
  */
 public function setDataFromEditmode($data)
 {
     if (!is_array($data)) {
         $data = array();
     }
     if ($doc = Document::getByPath($data["path"])) {
         if ($doc instanceof Document) {
             $data["internal"] = true;
             $data["internalId"] = $doc->getId();
             $data["internalType"] = "document";
         }
     }
     if (!$data["internal"]) {
         if ($asset = Asset::getByPath($data["path"])) {
             if ($asset instanceof Asset) {
                 $data["internal"] = true;
                 $data["internalId"] = $asset->getId();
                 $data["internalType"] = "asset";
             }
         }
     }
     $this->data = $data;
     return $this;
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:29,代码来源:Link.php

示例15: getFromCsvImport

 /**
  * fills object field data values from CSV Import String
  * @abstract
  * @param string $importValue
  * @param null|Model\Object\AbstractObject $object
  * @param mixed $params
  * @return Object\ClassDefinition\Data
  */
 public function getFromCsvImport($importValue, $object = null, $params = [])
 {
     $values = explode(",", $importValue);
     $value = [];
     foreach ($values as $element) {
         $tokens = explode(":", $element);
         if (count($tokens) == 2) {
             $type = $tokens[0];
             $path = $tokens[1];
             $value[] = Element\Service::getElementByPath($type, $path);
         } else {
             //fallback for old export files
             if ($el = Asset::getByPath($element)) {
                 $value[] = $el;
             } elseif ($el = Document::getByPath($element)) {
                 $value[] = $el;
             } elseif ($el = Object::getByPath($element)) {
                 $value[] = $el;
             }
         }
     }
     return $value;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:31,代码来源:Multihref.php


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