Pimcore\Model\Element\Service::getElementType PHP Méthode

getElementType() public static méthode

public static getElementType ( Pimcore\Model\Element\ElementInterface $element ) : string
$element Pimcore\Model\Element\ElementInterface $element
Résultat string
    public static function getElementType($element)
    {
        $type = null;
        if ($element instanceof Object\AbstractObject) {
            $type = "object";
        } elseif ($element instanceof Document) {
            $type = "document";
        } elseif ($element instanceof Asset) {
            $type = "asset";
        }
        return $type;
    }

Usage Example

Exemple #1
0
 public function extractRelations($element, $apiElementKeys, $recursive, $includeRelations)
 {
     $foundRelations = array();
     if ($includeRelations) {
         $dependency = $element->getDependencies();
         if ($dependency) {
             foreach ($dependency->getRequires() as $r) {
                 if ($e = Element\Service::getDependedElement($r)) {
                     if ($element->getId() != $e->getId() and !in_array(Element\Service::getElementType($e) . "_" . $e->getId(), $apiElementKeys)) {
                         $foundRelations[Element\Service::getElementType($e) . "_" . $e->getId()] = array("elementType" => Element\Service::getType($e), "element" => $e->getId(), "recursive" => false);
                     }
                 }
             }
         }
     }
     $childs = $element->getChilds();
     if ($recursive and $childs) {
         foreach ($childs as $child) {
             if (!in_array(Element\Service::getType($child) . "_" . $child->getId(), $apiElementKeys)) {
                 $foundRelations[Element\Service::getType($child) . "_" . $child->getId()] = array("elementType" => Element\Service::getType($child), "element" => $child->getId(), "recursive" => $recursive);
             }
         }
     }
     return $foundRelations;
 }
All Usage Examples Of Pimcore\Model\Element\Service::getElementType