mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-20 00:16:55 +02:00
77 lines
3.7 KiB
Markdown
77 lines
3.7 KiB
Markdown
title: Manifests
|
|
summary: Manage caches of file path maps and other expensive information
|
|
|
|
# Manifests
|
|
|
|
## Purpose
|
|
|
|
Manifests help to cache information which is too expensive to generate on each request.
|
|
Some manifests generate maps, e.g. class names to filesystem locations.
|
|
Others store aggregate information like nested configuration graphs.
|
|
|
|
## Storage
|
|
|
|
By default, manifests are serialised and cached via a cache generated by the [ManifestCacheFactory](api:SilverStripe\Core\Cache\ManifestCacheFactory).
|
|
This can be customised via `SS_MANIFESTCACHE` environment variable to point to either another
|
|
[CacheFactory](api:SilverStripe\Core\Cache\CacheFactory) or [CacheInterface](https://github.com/php-fig/cache/blob/master/src/CacheItemInterface.php)
|
|
implementor.
|
|
|
|
## Traversing the Filesystem
|
|
|
|
Since manifests usually extract their information from files in the webroot,
|
|
they require a powerful traversal tool: [FileFinder](api:SilverStripe\Assets\FileFinder).
|
|
The class provides filtering abilities for files and folders, as well as
|
|
callbacks for recursive traversal. Each manifest has its own implementation,
|
|
for example [ManifestFileFinder](api:SilverStripe\Core\Manifest\ManifestFileFinder), adding more domain specific filtering
|
|
like including themes, or excluding tests.
|
|
|
|
## PHP Class Manifest
|
|
|
|
The [ClassManifest](api:SilverStripe\Core\Manifest\ClassManifest) 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
|
|
|
|
The gathered information can be accessed through [ClassLoader::inst()](api:SilverStripe\Core\Manifest\ClassLoader::inst()),
|
|
as well as [ClassInfo](api:SilverStripe\Core\ClassInfo). Some useful commands of the `ClassInfo` API:
|
|
|
|
* `ClassInfo::subclassesFor($class)`: Returns a list of classes that inherit from the given class
|
|
* `ClassInfo::ancestry($class)`: Returns the passed class name along with all its parent class names
|
|
* `ClassInfo::implementorsOf($interfaceName)`: Returns all classes implementing the passed in interface
|
|
|
|
In the absence of a generic module API, it is also the primary way to identify
|
|
which modules are installed, through [ClassManifest::getModules()](api:SilverStripe\Core\Manifest\ClassManifest::getModules()).
|
|
A module is defined as a toplevel folder in the webroot which contains
|
|
either a `_config.php` file, or a `_config/` folder. Modules can be specifically
|
|
excluded from manifests by creating a blank `_manifest_exclude` file in the module folder.
|
|
|
|
By default, the finder implementation will exclude any classes stored in files within
|
|
a `tests/` folder, unless tests are executed.
|
|
|
|
## Theme Manifests
|
|
|
|
The [ThemeManifest](api:SilverStripe\View\ThemeManifest) class builds a manifest of all templates present in a directory,
|
|
in both modules and themes. Templates in `tests/` folders are automatically excluded.
|
|
The chapter on [template inheritance](../templates/template_inheritance) provides more details
|
|
on its operation.
|
|
|
|
## Config Manifest
|
|
|
|
The [ConfigManifest](api:ConfigManifest) loads builds a manifest of configuration items,
|
|
for both PHP and YAML. It also takes care of ordering and merging configuration fragments.
|
|
The chapter on [configuration](../configuration) has more details.
|
|
|
|
## Flushing
|
|
|
|
If a `?flush=1` query parameter is added to a URL, a call to `flush()` will be triggered
|
|
on any classes that implement the [Flushable](flushable) interface.
|
|
This enables developers to clear [manifest caches](manifests),
|
|
for example when adding new templates or PHP classes.
|
|
Note that you need to be in [dev mode](/getting_started/environment_management)
|
|
or logged-in as an administrator for flushing to take effect.
|