Pimcore\Model\Element\Service::getElementById PHP Method

getElementById() public static method

public static getElementById ( string $type, integer $id ) : Pimcore\Model\Element\ElementInterface
$type string
$id integer
return Pimcore\Model\Element\ElementInterface
    public static function getElementById($type, $id)
    {
        $element = null;
        if ($type == "asset") {
            $element = Asset::getById($id);
        } elseif ($type == "object") {
            $element = Object::getById($id);
        } elseif ($type == "document") {
            $element = Document::getById($id);
        }
        return $element;
    }

Usage Example

コード例 #1
0
ファイル: Multihref.php プロジェクト: solverat/pimcore
 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;
 }
All Usage Examples Of Pimcore\Model\Element\Service::getElementById