Exemplo n.º 1
0
	/**
	 * @param string $class
	 * @param bool $includeArgumentString Include the argument string in the return array,
	 *  FALSE would return array("Versioned"), TRUE returns array("Versioned('Stage','Live')").
	 * @return array Numeric array of either {@link DataExtension} classnames,
	 *  or eval'ed classname strings with constructor arguments.
	 */
	public static function get_extensions($class, $includeArgumentString = false) {
		$extensions = Config::inst()->get($class, 'extensions');

		if($includeArgumentString) {
			return $extensions;
		} else {
			$extensionClassnames = array();
			if($extensions) foreach($extensions as $extension) {
				$extensionClassnames[] = Extension::get_classname_without_arguments($extension);
			}
			return $extensionClassnames;
		}
	}
 /**
  * @param string $class
  * @param bool $includeArgumentString Include the argument string in the return array,
  *  FALSE would return array("Versioned"), TRUE returns array("Versioned('Stage','Live')").
  * @return array Numeric array of either {@link DataObjectDecorator} classnames,
  *  or eval'ed classname strings with constructor arguments.
  */
 function get_extensions($class, $includeArgumentString = false)
 {
     $extensions = self::get_static($class, 'extensions');
     if ($includeArgumentString) {
         return $extensions;
     } else {
         $extensionClassnames = array();
         if ($extensions) {
             foreach ($extensions as $extension) {
                 $extensionClassnames[] = Extension::get_classname_without_arguments($extension);
             }
         }
         return $extensionClassnames;
     }
 }
Exemplo n.º 3
0
 /**
  * @param string $class
  * @param bool $includeArgumentString Include the argument string in the return array,
  *  FALSE would return array("Versioned"), TRUE returns array("Versioned('Stage','Live')").
  * @return array Numeric array of either {@link DataExtension} classnames,
  *  or eval'ed classname strings with constructor arguments.
  */
 public static function get_extensions($class, $includeArgumentString = false)
 {
     $extensions = Config::inst()->get($class, 'extensions');
     if (empty($extensions)) {
         return array();
     }
     // Clean nullified named extensions
     $extensions = array_filter(array_values($extensions));
     if ($includeArgumentString) {
         return $extensions;
     } else {
         $extensionClassnames = array();
         if ($extensions) {
             foreach ($extensions as $extension) {
                 $extensionClassnames[] = Extension::get_classname_without_arguments($extension);
             }
         }
         return $extensionClassnames;
     }
 }
 /**
  * Return TRUE if a class has a specified extension.
  * This supports backwards-compatible format (static Object::has_extension($requiredExtension))
  * and new format ($object->has_extension($class, $requiredExtension))
  * @param string $classOrExtension if 1 argument supplied, the class name of the extension to
  *								 check for; if 2 supplied, the class name to test
  * @param string $requiredExtension used only if 2 arguments supplied
  * @param boolean $strict if the extension has to match the required extension and not be a subclass
  * @return bool Flag if the extension exists
  */
 public static function has_extension($classOrExtension, $requiredExtension = null, $strict = false)
 {
     //BC support
     if (func_num_args() > 1) {
         $class = $classOrExtension;
     } else {
         $class = get_called_class();
         $requiredExtension = $classOrExtension;
     }
     $requiredExtension = Extension::get_classname_without_arguments($requiredExtension);
     $extensions = self::get_extensions($class);
     foreach ($extensions as $extension) {
         if (strcasecmp($extension, $requiredExtension) === 0) {
             return true;
         }
         if (!$strict && is_subclass_of($extension, $requiredExtension)) {
             return true;
         }
     }
     return false;
 }
 /**
  * Gets all extensions directly on this class that extend FluentExtension
  *
  * @param Config $config
  * @param string $class
  * @return array
  */
 protected function getDirectExtensions($config, $class)
 {
     $extensions = $config->get($class, 'extensions', Config::UNINHERITED);
     $found = array();
     if ($extensions) {
         foreach ($extensions as $extension) {
             $extensionClass = ClassInfo::class_name(Extension::get_classname_without_arguments($extension));
             if ($extensionClass === 'FluentExtension' || is_subclass_of($extensionClass, 'FluentExtension')) {
                 $found[] = $extensionClass;
             }
         }
     }
     return $found;
 }