Pimcore\Model\Document\Page::getElement PHP Method

getElement() public method

public getElement ( string $name ) : Tag
$name string
return Tag
    public function getElement($name)
    {
        // check if a persona is requested for this page, if yes deliver a different version of the element (prefixed)
        if ($this->getUsePersona()) {
            $personaName = $this->getPersonaElementName($name);
            if ($this->hasElement($personaName)) {
                $name = $personaName;
            } else {
                // if there's no dedicated content for this persona, inherit from the "original" content (unprefixed)
                // and mark it as inherited so it is clear in the ui that the content is not specific to the selected persona
                // replace all occurrences of the persona prefix, this is needed because of block-prefixes
                $inheritedName = str_replace($this->getPersonaElementPrefix(), "", $name);
                $inheritedElement = parent::getElement($inheritedName);
                if ($inheritedElement) {
                    $inheritedElement = clone $inheritedElement;
                    $inheritedElement->setDao(null);
                    $inheritedElement->setName($personaName);
                    $inheritedElement->setInherited(true);
                    $this->setElement($personaName, $inheritedElement);
                    return $inheritedElement;
                }
            }
        }
        // delegate to default
        return parent::getElement($name);
    }

Usage Example

Example #1
0
 /**
  * @param $name
  *
  * @return Model\Document\Page
  */
 public function getElement($name)
 {
     $id = sprintf('%s%s%d', $name, $this->name, $this->index);
     $element = $this->doc->getElement($id);
     $element->suffixes = array($this->name);
     return $element;
 }
All Usage Examples Of Pimcore\Model\Document\Page::getElement