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;
}
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; }