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


PHP Service::getElementById方法代码示例

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


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

示例1: setElements

 public function setElements()
 {
     if (empty($this->elements)) {
         $this->elements = [];
         foreach ($this->elementIds as $elementId) {
             $el = Element\Service::getElementById($elementId["type"], $elementId["id"]);
             if ($el instanceof Element\ElementInterface) {
                 $this->elements[] = $el;
             }
         }
     }
     return $this;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:13,代码来源:Multihref.php

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

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

示例4: getRelationAttribute

 public function getRelationAttribute($attributeName)
 {
     $relationObjectArray = array();
     if ($this->relations[$attributeName]) {
         foreach ($this->relations[$attributeName] as $relation) {
             $relationObject = \Pimcore\Model\Element\Service::getElementById($relation['type'], $relation['id']);
             if ($relationObject) {
                 $relationObjectArray[] = $relationObject;
             }
         }
     }
     if (count($relationObjectArray) == 1) {
         return $relationObjectArray[0];
     } else {
         if (count($relationObjectArray) > 1) {
             return $relationObjectArray;
         } else {
             return null;
         }
     }
 }
开发者ID:ascertain,项目名称:NGshop,代码行数:21,代码来源:DefaultMockup.php

示例5: roleGetAction

 public function roleGetAction()
 {
     $role = User\Role::getById(intval($this->getParam("id")));
     // workspaces
     $types = ["asset", "document", "object"];
     foreach ($types as $type) {
         $workspaces = $role->{"getWorkspaces" . ucfirst($type)}();
         foreach ($workspaces as $workspace) {
             $el = Element\Service::getElementById($type, $workspace->getCid());
             if ($el) {
                 // direct injection => not nice but in this case ok ;-)
                 $workspace->path = $el->getRealFullPath();
             }
         }
     }
     // get available permissions
     $availableUserPermissionsList = new User\Permission\Definition\Listing();
     $availableUserPermissions = $availableUserPermissionsList->load();
     $availablePerspectives = \Pimcore\Config::getAvailablePerspectives(null);
     $this->_helper->json(["success" => true, "role" => $role, "permissions" => $role->generatePermissionList(), "classes" => $role->getClasses(), "docTypes" => $role->getDocTypes(), "availablePermissions" => $availableUserPermissions, "availablePerspectives" => $availablePerspectives]);
 }
开发者ID:solverat,项目名称:pimcore,代码行数:21,代码来源:UserController.php

示例6: getFromWebserviceImport

 /**
  * @param mixed $value
  * @param null $relatedObject
  * @param null $idMapper
  * @return mixed|void
  * @throws \Exception
  */
 public function getFromWebserviceImport($value, $relatedObject = null, $idMapper = null)
 {
     if (empty($value)) {
         return null;
     } else {
         $value = (array) $value;
         if (array_key_exists("id", $value) and array_key_exists("type", $value)) {
             $type = $value["type"];
             $id = $value["id"];
             if ($idMapper) {
                 $id = $idMapper->getMappedId($type, $id);
             }
             if ($id) {
                 $el = Element\Service::getElementById($type, $id);
             }
             if ($el instanceof Element\ElementInterface) {
                 return $el;
             } else {
                 if ($idMapper && $idMapper->ignoreMappingFailures()) {
                     $idMapper->recordMappingFailure("object", $relatedObject->getId(), $type, $value["id"]);
                 } else {
                     throw new \Exception("cannot get values from web service import - invalid href relation");
                 }
             }
         } else {
             throw new \Exception("cannot get values from web service import - invalid data");
         }
     }
 }
开发者ID:sfie,项目名称:pimcore,代码行数:36,代码来源:Href.php

示例7: unmarshal

 /** See marshal
  * @param mixed $value
  * @param Model\Object\AbstractObject $object
  * @param mixed $params
  * @return mixed
  */
 public function unmarshal($value, $object = null, $params = [])
 {
     if (is_array($value)) {
         $result = [];
         foreach ($value as $elementData) {
             $type = $elementData["type"];
             $id = $elementData["id"];
             $element = Element\Service::getElementById($type, $id);
             if ($element) {
                 $result[] = $element;
             }
         }
         return $result;
     }
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:21,代码来源:Objects.php

示例8: unlockPropagateAction

 public function unlockPropagateAction()
 {
     $success = false;
     $element = Element\Service::getElementById($this->getParam("type"), $this->getParam("id"));
     if ($element) {
         $element->unlockPropagate();
         $success = true;
     }
     $this->_helper->json(["success" => $success]);
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:10,代码来源:ElementController.php

示例9: getDataFromResource

 /**
  * @see Object\ClassDefinition\Data::getDataFromResource
  * @param Object\Data\Hotspotimage $data
  * @return Asset
  */
 public function getDataFromResource($data)
 {
     if ($data[$this->getName() . "__image"] || $data[$this->getName() . "__hotspots"]) {
         $metaData = $data[$this->getName() . "__hotspots"];
         // check if the data is JSON (backward compatibility)
         $md = json_decode($metaData, true);
         if (!$md) {
             $md = Serialize::unserialize($metaData);
         } else {
             if (is_array($md) && count($md)) {
                 $md["hotspots"] = $md;
             }
         }
         $hotspots = empty($md["hotspots"]) ? null : $md["hotspots"];
         $marker = empty($md["marker"]) ? null : $md["marker"];
         $crop = empty($md["crop"]) ? null : $md["crop"];
         $rewritePath = function ($data) {
             if (!is_array($data)) {
                 return array();
             }
             foreach ($data as &$element) {
                 if (array_key_exists("data", $element) && is_array($element["data"]) && count($element["data"]) > 0) {
                     foreach ($element["data"] as &$metaData) {
                         if (in_array($metaData["type"], array("object", "asset", "document"))) {
                             $el = Element\Service::getElementById($metaData["type"], $metaData["value"]);
                             $metaData["value"] = $el;
                         }
                     }
                 }
             }
             return $data;
         };
         $hotspots = $rewritePath($hotspots);
         $marker = $rewritePath($marker);
         return new Object\Data\Hotspotimage($data[$this->getName() . "__image"], $hotspots, $marker, $crop);
     }
     return null;
 }
开发者ID:Gerhard13,项目名称:pimcore,代码行数:43,代码来源:Hotspotimage.php

示例10: getMetadata

 /**
  * @return array
  */
 public function getMetadata($name = null, $language = null)
 {
     $convert = function ($metaData) {
         if (in_array($metaData["type"], ["asset", "document", "object"]) && is_numeric($metaData["data"])) {
             return Element\Service::getElementById($metaData["type"], $metaData["data"]);
         }
         return $metaData["data"];
     };
     if ($name) {
         if ($language === null) {
             if (\Zend_Registry::isRegistered("Zend_Locale")) {
                 $language = (string) \Zend_Registry::get("Zend_Locale");
             }
         }
         $data = null;
         foreach ($this->metadata as $md) {
             if ($md["name"] == $name) {
                 if ($language == $md["language"]) {
                     return $convert($md);
                 }
                 if (empty($md["language"])) {
                     $data = $md;
                 }
             }
         }
         if ($data) {
             return $convert($data);
         }
         return null;
     }
     $metaData = $this->metadata;
     foreach ($metaData as &$md) {
         $md["data"] = $convert($md);
     }
     return $metaData;
 }
开发者ID:Gerhard13,项目名称:pimcore,代码行数:39,代码来源:Asset.php

示例11: offsetGet

 /**
  * (PHP 5 &gt;= 5.0.0)<br/>
  * Offset to retrieve
  * @link http://php.net/manual/en/arrayaccess.offsetget.php
  * @param mixed $offset <p>
  * The offset to retrieve.
  * </p>
  * @return mixed Can return all value types.
  */
 public function offsetGet($offset)
 {
     if ($this->offsetExists($offset)) {
         if ($offset == "value" && in_array($this->type, ["object", "asset", "document"])) {
             return Model\Element\Service::getElementById($this->type, $this->value);
         } else {
             return $this->{$offset};
         }
     }
     return null;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:20,代码来源:MarkerHotspotItem.php

示例12: getFromWebserviceImport

 /**
  * @param mixed $value
  * @param null $relatedObject
  * @param null $idMapper
  * @return mixed|void
  * @throws \Exception
  */
 public function getFromWebserviceImport($value, $relatedObject = null, $idMapper = null)
 {
     if (empty($value)) {
         return null;
     } elseif (is_array($value)) {
         $hrefs = array();
         foreach ($value as $href) {
             // cast is needed to make it work for both SOAP and REST
             $href = (array) $href;
             if (is_array($href) and array_key_exists("id", $href) and array_key_exists("type", $href)) {
                 $type = $href["type"];
                 $id = $href["id"];
                 if ($idMapper) {
                     $id = $idMapper->getMappedId($type, $id);
                 }
                 $e = null;
                 if ($id) {
                     $e = Element\Service::getElementById($type, $id);
                 }
                 if ($e instanceof Element\ElementInterface) {
                     $hrefs[] = $e;
                 } else {
                     if (!$idMapper || !$idMapper->ignoreMappingFailures()) {
                         throw new \Exception("cannot get values from web service import - unknown element of type [ " . $href["type"] . " ] with id [" . $href["id"] . "] is referenced");
                     } else {
                         $idMapper->recordMappingFailure("object", $relatedObject->getId(), $type, $href["id"]);
                     }
                 }
             }
         }
         return $hrefs;
     } else {
         throw new \Exception("cannot get values from web service import - invalid data");
     }
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:42,代码来源:Multihref.php

示例13: unmarshal

 /** See marshal
  * @param mixed $value
  * @param Model\Object\AbstractObject $object
  * @param mixed $params
  * @return mixed
  */
 public function unmarshal($value, $object = null, $params = [])
 {
     if (is_array($value)) {
         $type = $value["type"];
         $id = $value["id"];
         return Element\Service::getElementById($type, $id);
     }
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:14,代码来源:Href.php

示例14: rewriteIdsService

 /**
  * Rewrites id from source to target, $idMapping contains
  * array(
  *  "document" => array(
  *      SOURCE_ID => TARGET_ID,
  *      SOURCE_ID => TARGET_ID
  *  ),
  *  "object" => array(...),
  *  "asset" => array(...)
  * )
  * @param mixed $data
  * @param array $idMapping
  * @return array
  */
 public function rewriteIdsService($data, $idMapping)
 {
     if (is_array($data)) {
         foreach ($data as &$element) {
             $id = $element->getId();
             $type = Element\Service::getElementType($element);
             if (array_key_exists($type, $idMapping) && array_key_exists($id, $idMapping[$type])) {
                 $element = Element\Service::getElementById($type, $idMapping[$type][$id]);
             }
         }
     }
     return $data;
 }
开发者ID:rolandstoll,项目名称:pimcore,代码行数:27,代码来源:AbstractRelations.php

示例15: checkValidity

 /**
  * Checks if data is valid for current data field
  *
  * @param mixed $data
  * @param boolean $omitMandatoryCheck
  * @throws \Exception
  */
 public function checkValidity($data, $omitMandatoryCheck = false)
 {
     if (!$omitMandatoryCheck and $this->getMandatory() and empty($data)) {
         throw new \Exception("Empty mandatory field [ " . $this->getName() . " ]");
     }
     $dependencies = Text::getDependenciesOfWysiwygText($data);
     if (is_array($dependencies)) {
         foreach ($dependencies as $key => $value) {
             $el = Element\Service::getElementById($value['type'], $value['id']);
             if (!$el) {
                 throw new \Exception("invalid dependency in wysiwyg text");
             }
         }
     }
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:22,代码来源:Wysiwyg.php


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