ClassInfo
class ClassInfo (View source)
Provides introspection information about the class tree.
It's a cached wrapper around the built-in class functions. SilverStripe uses class introspection heavily and without the caching it creates an unfortunate performance hit.
Methods
Returns the manifest of all classes which are present in the database.
Returns an array of the current class and all its ancestors and children which require a DB table.
Returns a list of classes that inherit from the given class.
Convert a class name in any case and return it as it was defined in PHP
Returns the passed class name along with all its parent class names in an array, sorted with the root class first.
Returns true if the given class implements the given interface
Returns all classes contained in a certain folder.
Determine if the given class method is implemented at the given comparison class
Helper to determine if the given object has a method
Parses a class-spec, such as "Versioned('Stage','Live')", as passed to create_from_string().
Returns a list of classes with a particular extension applied
Details
static array
allClasses()
Wrapper for classes getter.
static bool
exists(string $class)
Returns true if a class or interface name exists.
static bool
hasTable(string $tableName)
No description
static
reset_db_cache()
No description
static array
getValidSubClasses(string $class = SiteTree::class, bool $includeUnbacked = false)
Returns the manifest of all classes which are present in the database.
static array
dataClassesFor(string|object $nameOrObject)
Returns an array of the current class and all its ancestors and children which require a DB table.
static string
baseDataClass(string $class)
deprecated
deprecated
No description
static array
subclassesFor(string|object $nameOrObject, bool $includeBaseClass = true)
Returns a list of classes that inherit from the given class.
The resulting array includes the base class passed through the $class parameter as the first array value. Note that keys are lowercase, while the values are correct case.
Example usage:
ClassInfo::subclassesFor('BaseClass');
array(
'baseclass' => 'BaseClass',
'childclass' => 'ChildClass',
'grandchildclass' => 'GrandChildClass'
)
static string
class_name(string|object $nameOrObject)
Convert a class name in any case and return it as it was defined in PHP
eg: self::class_name('dataobJEct'); //returns 'DataObject'
static array
ancestry(string|object $nameOrObject, bool $tablesOnly = false)
Returns the passed class name along with all its parent class names in an array, sorted with the root class first.
static array
implementorsOf(string $interfaceName)
No description
static bool
classImplements(string $className, string $interfaceName)
Returns true if the given class implements the given interface
static array
classes_for_file(string $filePath)
Get all classes contained in a file.
static array
classes_for_folder(string $folderPath)
Returns all classes contained in a certain folder.
static bool
has_method_from(string $class, string $method, string $compclass)
Determine if the given class method is implemented at the given comparison class
static
table_for_object_field($candidateClass, $fieldName)
deprecated
deprecated
No description
static string
shortName(string|object $nameOrObject)
Strip namespace from class
static bool
hasMethod(object $object, string $method)
Helper to determine if the given object has a method
static array
parse_class_spec(string $classSpec)
Parses a class-spec, such as "Versioned('Stage','Live')", as passed to create_from_string().
Returns a 2-element array, with classname and arguments
static array
classesWithExtension(string $extensionClass, string $baseClassOrObject = DataObject::class, bool $includeBaseClass = false)
Returns a list of classes with a particular extension applied
This reflects all extensions added (or removed) both via the configuration API as well as dynamically using Extensible::add_extension() and Extensible::remove_extension().