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

getIdPath() public static method

public static getIdPath ( $element ) : string
$element
return string
    public static function getIdPath($element)
    {
        $path = "";
        if ($element instanceof ElementInterface) {
            $elementType = self::getElementType($element);
            $nid = $element->getParentId();
            $ne = self::getElementById($elementType, $nid);
        }
        if ($ne) {
            $path = self::getIdPath($ne, $path);
        }
        if ($element) {
            $path = $path . "/" . $element->getId();
        }
        return $path;
    }

Usage Example

 public function getDataByIdAction()
 {
     // check for lock
     if (Element\Editlock::isLocked($this->getParam("id"), "document")) {
         $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "document")));
     }
     Element\Editlock::lock($this->getParam("id"), "document");
     $snippet = Document\Snippet::getById($this->getParam("id"));
     $modificationDate = $snippet->getModificationDate();
     $snippet = $this->getLatestVersion($snippet);
     $snippet->setVersions(array_splice($snippet->getVersions(), 0, 1));
     $snippet->getScheduledTasks();
     $snippet->idPath = Element\Service::getIdPath($snippet);
     $snippet->userPermissions = $snippet->getUserPermissions();
     $snippet->setLocked($snippet->isLocked());
     $snippet->setParent(null);
     if ($snippet->getContentMasterDocument()) {
         $snippet->contentMasterDocumentPath = $snippet->getContentMasterDocument()->getRealFullPath();
     }
     $this->minimizeProperties($snippet);
     // unset useless data
     $snippet->setElements(null);
     if ($snippet->isAllowed("view")) {
         $this->_helper->json($snippet);
     }
     $this->_helper->json(false);
 }
All Usage Examples Of Pimcore\Model\Element\Service::getIdPath