ThemeResourceLoader
class ThemeResourceLoader implements Flushable, TemplateGlobalProvider (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 a themed resource or directory
Return the URL for a given themed resource or directory within the project.
Called by SSViewer to get a list of global variables to expose to the template, the static method to call on this class to get the value for those variables, and the class to use for casting the returned value for use in a template
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)
deprecated
deprecated
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 or directory
A themed resource can be any file that resides in a theme folder.
static string|null
themedResourceURL(string $resource)
Return the URL for a given themed resource or directory within the project.
A themed resource can be any file that resides in a theme folder.
static array
get_template_global_variables()
Called by SSViewer to get a list of global variables to expose to the template, the static method to call on this class to get the value for those variables, and the class to use for casting the returned value for use in a template
If the method to call is not included for a particular template variable, a method named the same as the template variable will be called
If the casting class is not specified for a particular template variable, ViewableData::$default_cast is used
The first letter of the template variable is case-insensitive. However the method name is always case sensitive.
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