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.
Properties
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 the root class (the first to extend from DataObject) for the passed class.
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.
Returns the table name in the class hierarchy which contains a given field column for a DataObject. If the field does not exist, this will return null.
Details
static
allClasses()
Wrapper for classes getter.
static bool
exists(string $class)
Returns true if a class or interface name exists.
static
hasTable($class)
No description
static
reset_db_cache()
No description
static array
getValidSubClasses(string $class = 'SiteTree', bool $includeUnbacked = false)
Returns the manifest of all classes which are present in the database.
static array
dataClassesFor(string|object $class)
Returns an array of the current class and all its ancestors and children which require a DB table.
static string
baseDataClass(string|object $class)
Returns the root class (the first to extend from DataObject) for the passed class.
static array
subclassesFor(mixed $class)
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.
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 $class, 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($interfaceName)
No description
static
classImplements($className, $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
has_method_from($class, $method, $compclass)
No description
static string
table_for_object_field(string $candidateClass, string $fieldName)
Returns the table name in the class hierarchy which contains a given field column for a DataObject. If the field does not exist, this will return null.
Note: In 3.x and below this method may return 'DataObject'. From 4.0 onwards null will be returned if a field is not a member of the object.