class SS_ClassManifest (View source)

A utility class which builds a manifest of all classes, interfaces and some additional items present in a directory, and caches it.

It finds the following information:

  • Class and interface names and paths.
  • All direct and indirect descendants of a class.
  • All implementors of an interface.
  • All module configuration files.

Constants

CONF_FILE

CONF_DIR

Methods

get_class_parser()

No description

get_imported_namespace_parser()

Create a {@link TokenisedRegularExpression} that extracts the namespaces imported with the 'use' keyword

__construct(string $base, bool $includeTests = false, bool $forceRegen = false, bool $cache = true)

Constructs and initialises a new class manifest, either loading the data from the cache or re-scanning for classes.

string|null
getItemPath(string $name)

Returns the file path to a class or interface if it exists in the manifest.

array
getClasses()

Returns a map of lowercased class names to file paths.

array
getClassNames()

Returns a lowercase array of all the class names in the manifest.

array
getDescendants()

Returns an array of all the descendant data.

array
getDescendantsOf(string|object $class)

Returns an array containing all the descendants (direct and indirect) of a class.

array
getInterfaces()

Returns a map of lowercased interface names to file locations.

array
getImplementors()

Returns a map of lowercased interface names to the classes the implement them.

array
getImplementorsOf(string $interface)

Returns an array containing the class names that implement a certain interface.

array
getConfigs()

Returns an array of paths to module config files.

array
getModules()

Returns an array of module names mapped to their paths.

regenerate(bool $cache = true)

Completely regenerates the manifest file.

handleDir($basename, $pathname, $depth)

No description

handleFile($basename, $pathname, $depth)

No description

Details

static TokenisedRegularExpression get_class_parser()

static TokenisedRegularExpression get_namespaced_class_parser()

static TokenisedRegularExpression get_namespace_parser()

static TokenisedRegularExpression get_interface_parser()

static TokenisedRegularExpression get_imported_namespace_parser()

Create a {@link TokenisedRegularExpression} that extracts the namespaces imported with the 'use' keyword

This searches symbols for a use followed by 1 or more namespaces which are optionally aliased using the as keyword. The relevant matching tokens are added one-by-one into an array (using save_to param).

eg: use Namespace\ClassName as Alias, OtherNamespace\ClassName;

__construct(string $base, bool $includeTests = false, bool $forceRegen = false, bool $cache = true)

Constructs and initialises a new class manifest, either loading the data from the cache or re-scanning for classes.

Parameters

string $base

The manifest base path.

bool $includeTests

Include the contents of "tests" directories.

bool $forceRegen

Force the manifest to be regenerated.

bool $cache

If the manifest is regenerated, cache it.

string|null getItemPath(string $name)

Returns the file path to a class or interface if it exists in the manifest.

Parameters

string $name

Return Value

string|null

array getClasses()

Returns a map of lowercased class names to file paths.

Return Value

array

array getClassNames()

Returns a lowercase array of all the class names in the manifest.

Return Value

array

array getDescendants()

Returns an array of all the descendant data.

Return Value

array

array getDescendantsOf(string|object $class)

Returns an array containing all the descendants (direct and indirect) of a class.

Parameters

string|object $class

Return Value

array

array getInterfaces()

Returns a map of lowercased interface names to file locations.

Return Value

array

array getImplementors()

Returns a map of lowercased interface names to the classes the implement them.

Return Value

array

array getImplementorsOf(string $interface)

Returns an array containing the class names that implement a certain interface.

Parameters

string $interface

Return Value

array

array getConfigs()

Returns an array of paths to module config files.

Return Value

array

array getModules()

Returns an array of module names mapped to their paths.

"Modules" in SilverStripe are simply directories with a _config.php file.

Return Value

array

regenerate(bool $cache = true)

Completely regenerates the manifest file.

Parameters

bool $cache

Cache the result.

handleDir($basename, $pathname, $depth)

Parameters

$basename
$pathname
$depth

handleFile($basename, $pathname, $depth)

Parameters

$basename
$pathname
$depth