ClassInfo
class ClassInfo
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
Wrapper for classes getter.
Returns true if a class or interface name exists.
No description
No description
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.
No description
Returns true if the given class implements the given interface
Get all classes contained in a file.
Returns all classes contained in a certain folder.
Determine if the given class method is implemented at the given comparison class
Strip namespace from 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().
Details
at line 66
static array
allClasses()
Wrapper for classes getter.
at line 77
static bool
exists(string $class)
Returns true if a class or interface name exists.
at line 90
static bool
hasTable(string $tableName)
at line 99
static
reset_db_cache()
at line 113
static array
getValidSubClasses(string $class = SiteTree::class, boolean $includeUnbacked = false)
Returns the manifest of all classes which are present in the database.
at line 138
static array
dataClassesFor(string|object $nameOrObject)
Returns an array of the current class and all its ancestors and children which require a DB table.
at line 162
static string
baseDataClass(string $class)
deprecated
deprecated 4.0.0:5.0.0
at line 189
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'
)
at line 216
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'
at line 246
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.
at line 276
static array
implementorsOf(string $interfaceName)
at line 288
static bool
classImplements(string $className, string $interfaceName)
Returns true if the given class implements the given interface
at line 301
static array
classes_for_file(string $filePath)
Get all classes contained in a file.
at line 324
static array
classes_for_folder(string $folderPath)
Returns all classes contained in a certain folder.
at line 349
static bool
has_method_from(string $class, string $method, string $compclass)
Determine if the given class method is implemented at the given comparison class
at line 375
static
table_for_object_field($candidateClass, $fieldName)
deprecated
deprecated 4.0.0:5.0.0
at line 387
static string
shortName(string|object $nameOrObject)
Strip namespace from class
at line 401
static bool
hasMethod(object $object, string $method)
Helper to determine if the given object has a method
at line 420
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