Pimcore\Model\Object\AbstractObject::getByPath PHP Method

getByPath() public static method

public static getByPath ( string $path ) : self
$path string
return self
    public static function getByPath($path)
    {
        $path = Model\Element\Service::correctPath($path);
        try {
            $object = new self();
            if (Tool::isValidPath($path)) {
                $object->getDao()->getByPath($path);
                return self::getById($object->getId());
            }
        } catch (\Exception $e) {
            Logger::warning($e->getMessage());
        }
        return null;
    }

Usage Example

 /**
  * @return AbstractObject|\Pimcore\Model\Object\Participation
  * @throws \Exception
  */
 public function makeParticipation()
 {
     $objectFolderPath = Plugin::getConfig()->get(Plugin::CONFIG_OBJECTFOLDERPATH);
     $objectFolder = AbstractObject::getByPath($objectFolderPath);
     if (!$objectFolder instanceof Folder) {
         throw new \Exception("Error: objectFolderPath [{$objectFolderPath}] " . "is not a valid object folder.");
     }
     // create basic object stuff
     $key = $this->createParticipationKey();
     $participation = new Participation();
     $participation->setKey($key);
     $participation->setParent($objectFolder);
     $participation->setPublished(true);
     $participation->setCreationDate(time());
     $participation->SetIpCreated($_SERVER['REMOTE_ADDR']);
     $confirmation = $this->makeConfirmation();
     $participation->setConfirmationCode($confirmation->createCode());
     return $participation;
 }
All Usage Examples Of Pimcore\Model\Object\AbstractObject::getByPath