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


PHP Object::getByPath方法代码示例

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


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

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

示例2: getFromCsvImport

 /**
  * @param $importValue
  * @return mixed|null|Asset|Document|Element\ElementInterface
  */
 public function getFromCsvImport($importValue)
 {
     $value = null;
     $values = explode(":", $importValue);
     if (count($values) == 2) {
         $type = $values[0];
         $path = $values[1];
         $value = Element\Service::getElementByPath($type, $path);
     } else {
         //fallback for old export files
         if ($el = Asset::getByPath($importValue)) {
             $value = $el;
         } else {
             if ($el = Document::getByPath($importValue)) {
                 $value = $el;
             } else {
                 if ($el = Object::getByPath($importValue)) {
                     $value = $el;
                 }
             }
         }
     }
     return $value;
 }
开发者ID:sfie,项目名称:pimcore,代码行数:28,代码来源:Href.php

示例3: copyAction

 public function copyAction()
 {
     $success = false;
     $message = "";
     $sourceId = intval($this->getParam("sourceId"));
     $source = Object::getById($sourceId);
     $session = Tool\Session::get("pimcore_copy");
     $targetId = intval($this->getParam("targetId"));
     if ($this->getParam("targetParentId")) {
         $sourceParent = Object::getById($this->getParam("sourceParentId"));
         // this is because the key can get the prefix "_copy" if the target does already exists
         if ($session->{$this->getParam("transactionId")}["parentId"]) {
             $targetParent = Object::getById($session->{$this->getParam("transactionId")}["parentId"]);
         } else {
             $targetParent = Object::getById($this->getParam("targetParentId"));
         }
         $targetPath = preg_replace("@^" . $sourceParent->getFullPath() . "@", $targetParent . "/", $source->getPath());
         $target = Object::getByPath($targetPath);
     } else {
         $target = Object::getById($targetId);
     }
     if ($target->isAllowed("create")) {
         $source = Object::getById($sourceId);
         if ($source != null) {
             try {
                 if ($this->getParam("type") == "child") {
                     $newObject = $this->_objectService->copyAsChild($target, $source);
                     $session->{$this->getParam("transactionId")}["idMapping"][(int) $source->getId()] = (int) $newObject->getId();
                     // this is because the key can get the prefix "_copy" if the target does already exists
                     if ($this->getParam("saveParentId")) {
                         $session->{$this->getParam("transactionId")}["parentId"] = $newObject->getId();
                         Tool\Session::writeClose();
                     }
                 } elseif ($this->getParam("type") == "replace") {
                     $this->_objectService->copyContents($target, $source);
                 }
                 $success = true;
             } catch (\Exception $e) {
                 \Logger::err($e);
                 $success = false;
                 $message = $e->getMessage() . " in object " . $source->getFullPath() . " [id: " . $source->getId() . "]";
             }
         } else {
             \Logger::error("could not execute copy/paste, source object with id [ {$sourceId} ] not found");
             $this->_helper->json(array("success" => false, "message" => "source object not found"));
         }
     } else {
         \Logger::error("could not execute copy/paste because of missing permissions on target [ " . $targetId . " ]");
         $this->_helper->json(array("error" => false, "message" => "missing_permission"));
     }
     $this->_helper->json(array("success" => $success, "message" => $message));
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:52,代码来源:ObjectController.php

示例4: getFromCsvImport

 /**
  * @param $importValue
  * @return array|mixed
  */
 public function getFromCsvImport($importValue)
 {
     $values = explode(",", $importValue);
     $value = array();
     foreach ($values as $element) {
         if ($el = Object::getByPath($element)) {
             $value[] = $el;
         }
     }
     return $value;
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:15,代码来源:Objects.php

示例5: getFromCsvImport

 /**
  * @param $importValue
  * @param null|Model\Object\AbstractObject $object
  * @param mixed $params
  * @return array|mixed
  */
 public function getFromCsvImport($importValue, $object = null, $params = [])
 {
     $values = explode(",", $importValue);
     $value = [];
     foreach ($values as $element) {
         if ($el = Object::getByPath($element)) {
             $value[] = $el;
         }
     }
     return $value;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:17,代码来源:Objects.php

示例6: getFromCsvImport

 /**
  * @param $importValue
  * @return array|mixed
  */
 public function getFromCsvImport($importValue)
 {
     $values = explode(",", $importValue);
     $value = array();
     foreach ($values as $element) {
         if ($el = Object::getByPath($element)) {
             $className = Tool::getModelClassMapping('\\Pimcore\\Model\\Object\\Data\\ObjectMetadata');
             $metaObject = new $className($this->getName(), $this->getColumnKeys(), $el);
             $value[] = $metaObject;
         }
     }
     return $value;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:17,代码来源:ObjectsMetadata.php

示例7: importProcessAction

 public function importProcessAction()
 {
     $success = true;
     $parentId = $this->getParam("parentId");
     $job = $this->getParam("job");
     $id = $this->getParam("id");
     $mappingRaw = \Zend_Json::decode($this->getParam("mapping"));
     $class = Object\ClassDefinition::getById($this->getParam("classId"));
     $skipFirstRow = $this->getParam("skipHeadRow") == "true";
     $fields = $class->getFieldDefinitions();
     $file = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/import_" . $id;
     // currently only csv supported
     // determine type
     $dialect = Tool\Admin::determineCsvDialect(PIMCORE_SYSTEM_TEMP_DIRECTORY . "/import_" . $id . "_original");
     $count = 0;
     if (($handle = fopen($file, "r")) !== false) {
         $data = fgetcsv($handle, 0, $dialect->delimiter, $dialect->quotechar, $dialect->escapechar);
     }
     if ($skipFirstRow && $job == 1) {
         //read the next row, we need to skip the head row
         $data = fgetcsv($handle, 0, $dialect->delimiter, $dialect->quotechar, $dialect->escapechar);
     }
     $tmpFile = $file . "_tmp";
     $tmpHandle = fopen($tmpFile, "w+");
     while (!feof($handle)) {
         $buffer = fgets($handle);
         fwrite($tmpHandle, $buffer);
     }
     fclose($handle);
     fclose($tmpHandle);
     unlink($file);
     rename($tmpFile, $file);
     // prepare mapping
     foreach ($mappingRaw as $map) {
         if ($map[0] !== "" && $map[1] && !empty($map[2])) {
             $mapping[$map[2]] = $map[0];
         } else {
             if ($map[1] == "published (system)") {
                 $mapping["published"] = $map[0];
             } else {
                 if ($map[1] == "type (system)") {
                     $mapping["type"] = $map[0];
                 }
             }
         }
     }
     // create new object
     $className = "\\Pimcore\\Model\\Object\\" . ucfirst($this->getParam("className"));
     $className = Tool::getModelClassMapping($className);
     $parent = Object::getById($this->getParam("parentId"));
     $objectKey = "object_" . $job;
     if ($this->getParam("filename") == "id") {
         $objectKey = null;
     } else {
         if ($this->getParam("filename") != "default") {
             $objectKey = File::getValidFilename($data[$this->getParam("filename")]);
         }
     }
     $overwrite = false;
     if ($this->getParam("overwrite") == "true") {
         $overwrite = true;
     }
     if ($parent->isAllowed("create")) {
         $intendedPath = $parent->getFullPath() . "/" . $objectKey;
         if ($overwrite) {
             $object = Object::getByPath($intendedPath);
             if (!$object instanceof Object\Concrete) {
                 //create new object
                 $object = new $className();
             } else {
                 if ($object instanceof Object\Concrete and !$object instanceof $className) {
                     //delete the old object it is of a different class
                     $object->delete();
                     $object = new $className();
                 } else {
                     if ($object instanceof Object\Folder) {
                         //delete the folder
                         $object->delete();
                         $object = new $className();
                     } else {
                         //use the existing object
                     }
                 }
             }
         } else {
             $counter = 1;
             while (Object::getByPath($intendedPath) != null) {
                 $objectKey .= "_" . $counter;
                 $intendedPath = $parent->getFullPath() . "/" . $objectKey;
                 $counter++;
             }
             $object = new $className();
         }
         $object->setClassId($this->getParam("classId"));
         $object->setClassName($this->getParam("className"));
         $object->setParentId($this->getParam("parentId"));
         $object->setKey($objectKey);
         $object->setCreationDate(time());
         $object->setUserOwner($this->getUser()->getId());
         $object->setUserModification($this->getUser()->getId());
//.........这里部分代码省略.........
开发者ID:cannonerd,项目名称:pimcore,代码行数:101,代码来源:ObjectHelperController.php

示例8: indexAction

 public function indexAction()
 {
     // IE compatibility
     //$this->getResponse()->setHeader("X-UA-Compatible", "IE=8; IE=9", true);
     // clear open edit locks for this session (in the case of a reload, ...)
     \Pimcore\Model\Element\Editlock::clearSession(session_id());
     // check maintenance
     $maintenance_enabled = false;
     $manager = Model\Schedule\Manager\Factory::getManager("maintenance.pid");
     $lastExecution = $manager->getLastExecution();
     if ($lastExecution) {
         if (time() - $lastExecution < 610) {
             // maintenance script should run at least every 10 minutes + a little tolerance
             $maintenance_enabled = true;
         }
     }
     $this->view->maintenance_enabled = \Zend_Json::encode($maintenance_enabled);
     // configuration
     $sysConfig = Config::getSystemConfig();
     $this->view->config = $sysConfig;
     //mail settings
     $mailIncomplete = false;
     if ($sysConfig->email) {
         if (!$sysConfig->email->debug->emailaddresses) {
             $mailIncomplete = true;
         }
         if (!$sysConfig->email->sender->email) {
             $mailIncomplete = true;
         }
         if ($sysConfig->email->method == "smtp" && !$sysConfig->email->smtp->host) {
             $mailIncomplete = true;
         }
     }
     $this->view->mail_settings_complete = \Zend_Json::encode(!$mailIncomplete);
     // report configuration
     $this->view->report_config = Config::getReportConfig();
     // customviews config
     $cvConfig = Tool::getCustomViewConfig();
     $cvData = array();
     if ($cvConfig) {
         foreach ($cvConfig as $node) {
             $tmpData = $node;
             $rootNode = Model\Object::getByPath($tmpData["rootfolder"]);
             if ($rootNode) {
                 $tmpData["rootId"] = $rootNode->getId();
                 $tmpData["allowedClasses"] = explode(",", $tmpData["classes"]);
                 $tmpData["showroot"] = (bool) $tmpData["showroot"];
                 $cvData[] = $tmpData;
             }
         }
     }
     $this->view->customview_config = $cvData;
     // upload limit
     $max_upload = filesize2bytes(ini_get("upload_max_filesize") . "B");
     $max_post = filesize2bytes(ini_get("post_max_size") . "B");
     $upload_mb = min($max_upload, $max_post);
     $this->view->upload_max_filesize = $upload_mb;
     // csrf token
     $user = $this->getUser();
     $this->view->csrfToken = Tool\Session::useSession(function ($adminSession) use($user) {
         if (!isset($adminSession->csrfToken) && !$adminSession->csrfToken) {
             $adminSession->csrfToken = sha1(microtime() . $user->getName() . uniqid());
         }
         return $adminSession->csrfToken;
     });
     if (\Pimcore\Tool\Admin::isExtJS6()) {
         $this->forward("index6");
     }
 }
开发者ID:jansarmir,项目名称:pimcore,代码行数:69,代码来源:IndexController.php

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

示例10: restore

 /**
  *
  */
 public function restore()
 {
     $raw = file_get_contents($this->getStoreageFile());
     $element = Serialize::unserialize($raw);
     // check for element with the same name
     if ($element instanceof Document) {
         $indentElement = Document::getByPath($element->getFullpath());
         if ($indentElement) {
             $element->setKey($element->getKey() . "_restore");
         }
     } else {
         if ($element instanceof Asset) {
             $indentElement = Asset::getByPath($element->getFullpath());
             if ($indentElement) {
                 $element->setFilename($element->getFilename() . "_restore");
             }
         } else {
             if ($element instanceof Object\AbstractObject) {
                 $indentElement = Object::getByPath($element->getFullpath());
                 if ($indentElement) {
                     $element->setKey($element->getKey() . "_restore");
                 }
             }
         }
     }
     $this->restoreChilds($element);
     $this->delete();
 }
开发者ID:rolandstoll,项目名称:pimcore,代码行数:31,代码来源:Item.php

示例11: objectFormAction

 public function objectFormAction()
 {
     $success = false;
     // getting parameters is very easy ... just call $this->getParam("yorParamKey"); regardless if's POST or GET
     if ($this->getParam("firstname") && $this->getParam("lastname") && $this->getParam("email") && $this->getParam("terms")) {
         $success = true;
         // for this example the class "person" and "inquiry" is used
         // first we create a person, then we create an inquiry object and link them together
         // check for an existing person with this name
         $person = Object\Person::getByEmail($this->getParam("email"), 1);
         if (!$person) {
             // if there isn't an existing, ... create one
             $filename = \Pimcore\File::getValidFilename($this->getParam("email"));
             // first we need to create a new object, and fill some system-related information
             $person = new Object\Person();
             $person->setParent(Object::getByPath("/crm/inquiries"));
             // we store all objects in /crm
             $person->setKey($filename);
             // the filename of the object
             $person->setPublished(true);
             // yep, it should be published :)
             // of course this needs some validation here in production...
             $person->setGender($this->getParam("gender"));
             $person->setFirstname($this->getParam("firstname"));
             $person->setLastname($this->getParam("lastname"));
             $person->setEmail($this->getParam("email"));
             $person->setDateRegister(new \DateTime());
             $person->save();
         }
         // now we create the inquiry object and link the person in it
         $inquiryFilename = \Pimcore\File::getValidFilename(date("Y-m-d") . "~" . $person->getEmail());
         $inquiry = new Object\Inquiry();
         $inquiry->setParent(Object::getByPath("/inquiries"));
         // we store all objects in /inquiries
         $inquiry->setKey($inquiryFilename);
         // the filename of the object
         $inquiry->setPublished(true);
         // yep, it should be published :)
         // now we fill in the data
         $inquiry->setMessage($this->getParam("message"));
         $inquiry->setPerson($person);
         $inquiry->setDate(new \DateTime());
         $inquiry->setTerms((bool) $this->getParam("terms"));
         $inquiry->save();
     } elseif ($this->getRequest()->isPost()) {
         $this->view->error = true;
     }
     // do some validation & assign the parameters to the view
     foreach (["firstname", "lastname", "email", "message", "terms"] as $key) {
         if ($this->getParam($key)) {
             $this->view->{$key} = htmlentities(strip_tags($this->getParam($key)));
         }
     }
     // assign the status to the view
     $this->view->success = $success;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:56,代码来源:AdvancedController.php

示例12: getElementByPath

 /**
  * @static
  * @param  string $type
  * @param  string $path
  * @return ElementInterface
  */
 public static function getElementByPath($type, $path)
 {
     if ($type == "asset") {
         $element = Asset::getByPath($path);
     } else {
         if ($type == "object") {
             $element = Object::getByPath($path);
         } else {
             if ($type == "document") {
                 $element = Document::getByPath($path);
             }
         }
     }
     return $element;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:21,代码来源:Service.php

示例13: restore

 /**
  *
  */
 public function restore($user = null)
 {
     $raw = file_get_contents($this->getStoreageFile());
     $element = Serialize::unserialize($raw);
     // check for element with the same name
     if ($element instanceof Document) {
         $indentElement = Document::getByPath($element->getRealFullPath());
         if ($indentElement) {
             $element->setKey($element->getKey() . "_restore");
         }
     } elseif ($element instanceof Asset) {
         $indentElement = Asset::getByPath($element->getRealFullPath());
         if ($indentElement) {
             $element->setFilename($element->getFilename() . "_restore");
         }
     } elseif ($element instanceof Object\AbstractObject) {
         $indentElement = Object::getByPath($element->getRealFullPath());
         if ($indentElement) {
             $element->setKey($element->getKey() . "_restore");
         }
     }
     if (\Pimcore\Tool\Admin::getCurrentUser()) {
         $parent = $element->getParent();
         if (!$parent->isAllowed("publish")) {
             throw new \Exception("Not sufficient permissions");
         }
     }
     $this->restoreChilds($element);
     $this->delete();
 }
开发者ID:solverat,项目名称:pimcore,代码行数:33,代码来源:Item.php

示例14: getFromCsvImport

 /**
  * @param $importValue
  * @param null|Model\Object\AbstractObject $object
  * @param mixed $params
  * @return array|mixed
  */
 public function getFromCsvImport($importValue, $object = null, $params = [])
 {
     $values = explode(",", $importValue);
     $value = [];
     foreach ($values as $element) {
         if ($el = Object::getByPath($element)) {
             $metaObject = \Pimcore::getDiContainer()->make('Pimcore\\Model\\Object\\Data\\ObjectMetadata', ["fieldname" => $this->getName(), "columns" => $this->getColumnKeys(), "object" => $el]);
             $value[] = $metaObject;
         }
     }
     return $value;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:18,代码来源:ObjectsMetadata.php


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