Пример #1
0
 /**
  * Determine and validate the object class name from its type
  *
  * @param Type $type Object type
  * @return string Object class name
  * @throws InvalidArgumentException If the object type is invalid
  */
 protected static function objectClassFromType(Type $type)
 {
     // If the object type is invalid
     $objectType = $type->getType();
     $objectClass = 'Apparat\\Object\\Application\\Model\\Object\\' . ucfirst($objectType);
     if (!TypeService::isEnabled($objectType) || !class_exists($objectClass)) {
         throw new InvalidArgumentException(sprintf('Invalid object type "%s"', $objectType), InvalidArgumentException::INVALID_OBJECT_TYPE);
     }
     return $objectClass;
 }
Пример #2
0
 /**
  * Return whether a particular object type is supported
  *
  * @param string $type Object type
  * @return bool Object type is supported
  */
 public static function supportsType($type)
 {
     return TypeService::isEnabled($type);
 }