ThemeResourceLoader
class ThemeResourceLoader implements Flushable (View source)
Handles finding templates from a stack of template manifest objects.
Properties
protected | string | $base | The base path of the application |
|
protected | ThemeList[] | $sets | List of template "sets" that contain a test manifest, and have an alias. |
|
protected | CacheInterface | $cache |
Methods
Given a theme identifier, determine the path from the root directory
Attempts to find possible candidate templates from a set of template names from modules, current theme directory and finally the application folder.
Resolve themed javascript path
Resolve all themes to the list of root folders relative to site root
Details
static ThemeResourceLoader
inst()
No description
static
set_instance(ThemeResourceLoader $instance)
Set instance
__construct($base = null)
No description
addSet(string $set, ThemeList $manifest)
Add a new theme manifest for a given identifier. E.g. '$default'
ThemeList
getSet(string $set)
Get a named theme set
string
getPath(string $identifier)
Given a theme identifier, determine the path from the root directory
The mapping from $identifier to path follows these rules:
- A simple theme name ('mytheme') which maps to the standard themes dir (/themes/mytheme)
- A theme path with a leading slash ('/mymodule/themes/mytheme') which maps directly to that path.
- or a vendored theme path. (vendor/mymodule:mytheme) which maps to the nested 'theme' within that module. ('/mymodule/themes/mytheme').
- A vendored module with no nested theme (vendor/mymodule) which maps to the root directory of that module. ('/mymodule').
string
findTemplate(string|array $template, array $themes = null)
Attempts to find possible candidate templates from a set of template names from modules, current theme directory and finally the application folder.
The template names can be passed in as plain strings, or be in the format "type/name", where type is the type of template to search for (e.g. Includes, Layout).
The results of this method will be cached for future use.
string
findThemedCSS(string $name, array $themes = null)
Resolve themed CSS path
string
findThemedJavascript(string $name, array $themes = null)
Resolve themed javascript path
A javascript file in the current theme path name 'themename/javascript/$name.js' is first searched for, and it that doesn't exist and the module parameter is set then a javascript file with that name in the module is used.
string
findThemedResource(string $resource, array $themes = null)
Resolve a themed resource
A themed resource and be any file that resides in a theme folder.
array
getThemePaths(array $themes = null)
Resolve all themes to the list of root folders relative to site root
static
flush()
Flush any cached data
CacheInterface
getCache()
No description
ThemeResourceLoader
setCache(CacheInterface $cache)
No description