Pimcore\Model\Object\ClassDefinition::getByName PHP Method

getByName() public static method

public static getByName ( string $name ) : self
$name string
return self
    public static function getByName($name)
    {
        try {
            $class = new self();
            $id = $class->getDao()->getIdByName($name);
            if ($id) {
                return self::getById($id);
            } else {
                throw new \Exception("There is no class with the name: " . $name);
            }
        } catch (\Exception $e) {
            Logger::error($e);
            return null;
        }
    }

Usage Example

Example #1
0
 /**
  * @param string $name
  */
 public function removeClass($name)
 {
     $class = ClassDefinition::getByName($name);
     if ($class) {
         $class->delete();
     }
 }
All Usage Examples Of Pimcore\Model\Object\ClassDefinition::getByName