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

isPublished() public static method

determines whether an element is published
public static isPublished ( Pimcore\Model\Element\ElementInterface $element = null ) : boolean
$element Pimcore\Model\Element\ElementInterface
return boolean
    public static function isPublished($element = null)
    {
        if ($element instanceof ElementInterface) {
            if (method_exists($element, "isPublished")) {
                return $element->isPublished();
            } else {
                return true;
            }
        }
        return false;
    }

Usage Example

Example #1
0
 public function preGetData($object, $params = array())
 {
     $data = null;
     if ($object instanceof Object\Concrete) {
         $data = $object->{$this->getName()};
         if ($this->getLazyLoading() and !in_array($this->getName(), $object->getO__loadedLazyFields())) {
             //$data = $this->getDataFromResource($object->getRelationData($this->getName(),true,null));
             $data = $this->load($object, array("force" => true));
             $setter = "set" . ucfirst($this->getName());
             if (method_exists($object, $setter)) {
                 $object->{$setter}($data);
             }
         }
     } else {
         if ($object instanceof Object\Localizedfield) {
             $data = $params["data"];
         } else {
             if ($object instanceof Object\Fieldcollection\Data\AbstractData) {
                 $data = $object->{$this->getName()};
             } else {
                 if ($object instanceof Object\Objectbrick\Data\AbstractData) {
                     $data = $object->{$this->getName()};
                 }
             }
         }
     }
     if (Object\AbstractObject::doHideUnpublished() and is_array($data)) {
         $publishedList = array();
         foreach ($data as $listElement) {
             if (Element\Service::isPublished($listElement)) {
                 $publishedList[] = $listElement;
             }
         }
         return $publishedList;
     }
     return is_array($data) ? $data : array();
 }
All Usage Examples Of Pimcore\Model\Element\Service::isPublished