Manager
in package
Manage Angular resources.
Table of Contents
Properties
- $cache : CRM_Utils_Cache_Interface
- $changeSets : array<string|int, mixed>
- $res : CRM_Core_Resources
- $partials : array<string|int, mixed>
- Static cache of html partials.
Methods
- __construct() : mixed
- add() : Manager
- clear() : static
- Clear out any runtime-cached metadata.
- getChangeSets() : array<string|int, mixed>
- getModule() : array<string|int, mixed>
- Get the descriptor for an Angular module.
- getModules() : array<string|int, mixed>
- Get a list of AngularJS modules which should be autoloaded.
- getPartials() : array<string|int, mixed>
- Get the partial HTML documents for a module.
- getRawPartials() : array<string|int, mixed>
- Get the partial HTML documents for a module (unfiltered).
- getResources() : array<string|int, mixed>
- Get resources for one or more modules, applying any changesets.
- getStrings() : array<string|int, mixed>
- Get list of translatable strings for a module.
- getTranslatedStrings() : array<string|int, mixed>
- Get list of translated strings for a module.
- resolveDefaultModules() : array<string|int, mixed>
- Get a list of Angular modules that should be loaded on the given base-page.
- resolveDependencies() : array<string|int, mixed>
- Resolve a full list of Angular dependencies.
- resolvePatterns() : array<string|int, mixed>
- Convert any globs in an Angular module to file names.
Properties
$cache
protected
CRM_Utils_Cache_Interface
$cache
$changeSets
protected
array<string|int, mixed>
$changeSets
= NULL
Array(string $name => ChangeSet $change).
$res
protected
CRM_Core_Resources
$res
= NULL
$partials
Static cache of html partials.
private
array<string|int, mixed>
$partials
= []
Stashing it here because it's too big to store in SqlCache FIXME: So that probably means we shouldn't be storing in memory either!
Methods
__construct()
public
__construct(CRM_Core_Resources $res[, mixed $cache = NULL ]) : mixed
Parameters
- $res : CRM_Core_Resources
-
The resource manager.
- $cache : mixed = NULL
add()
public
add(ChangeSet $changeSet) : Manager
Parameters
- $changeSet : ChangeSet
Return values
Managerclear()
Clear out any runtime-cached metadata.
public
clear() : static
This is useful if, eg, you have recently added or destroyed Angular modules.
Return values
staticgetChangeSets()
public
getChangeSets() : array<string|int, mixed>
Return values
array<string|int, mixed> —Array(string $name => ChangeSet $changeSet).
getModule()
Get the descriptor for an Angular module.
public
getModule(string $moduleName) : array<string|int, mixed>
Parameters
- $moduleName : string
Tags
Return values
array<string|int, mixed> —Details about the module:
- ext: string, the name of the Civi extension which defines the module
- js: array(string $relativeFilePath).
- css: array(string $relativeFilePath).
- partials: array(string $relativeFilePath).
getModules()
Get a list of AngularJS modules which should be autoloaded.
public
getModules() : array<string|int, mixed>
Return values
array<string|int, mixed> —Each item has some combination of these keys:
- ext: string The Civi extension which defines the Angular module.
- js: array(string $relativeFilePath) List of JS files (relative to the extension).
- css: array(string $relativeFilePath) List of CSS files (relative to the extension).
- partials: array(string $relativeFilePath) A list of partial-HTML folders (relative to the extension). This will be mapped to "~/moduleName" by crmResource.
- settings: array(string $key => mixed $value) List of settings to preload.
getPartials()
Get the partial HTML documents for a module.
public
getPartials(string $name) : array<string|int, mixed>
Parameters
- $name : string
-
Angular module name.
Tags
Return values
array<string|int, mixed> —Array(string $extFilePath => string $html)
getRawPartials()
Get the partial HTML documents for a module (unfiltered).
public
getRawPartials(string $name) : array<string|int, mixed>
Parameters
- $name : string
-
Angular module name.
Tags
Return values
array<string|int, mixed> —Array(string $extFilePath => string $html)
getResources()
Get resources for one or more modules, applying any changesets.
public
getResources(string|array<string|int, mixed> $moduleNames, string $resType, string $refType) : array<string|int, mixed>
NOTE: The output of this function is a little quirky; depending on the type of resource requested, the results will either be a non-associative array (for path and url-type resources) or an array indexed by moduleName (for pass-thru resources like settingsFactory, requires, permissions, bundles).
Note: ChangeSets will be applied
Parameters
- $moduleNames : string|array<string|int, mixed>
-
List of module names.
- $resType : string
-
Type of resource ('js', 'css', 'settings').
- $refType : string
-
Type of reference to the resource ('cacheUrl', 'rawUrl', 'path', 'settings').
Tags
Return values
array<string|int, mixed> —Indexed or non-associative array, depending on resource requested (see note)
getStrings()
Get list of translatable strings for a module.
public
getStrings(string $name) : array<string|int, mixed>
Parameters
- $name : string
-
Angular module name.
Return values
array<string|int, mixed> —Translatable strings.
getTranslatedStrings()
Get list of translated strings for a module.
public
getTranslatedStrings(string $name) : array<string|int, mixed>
Parameters
- $name : string
-
Angular module name.
Return values
array<string|int, mixed> —Translated strings: array(string $orig => string $translated).
resolveDefaultModules()
Get a list of Angular modules that should be loaded on the given base-page.
public
resolveDefaultModules(string $basePage) : array<string|int, mixed>
Parameters
- $basePage : string
-
The name of the base-page for which we want a list of moudles.
Return values
array<string|int, mixed> —List of Angular modules. Ex: array('crmMailing', 'crmUi', 'crmUtil', 'ngRoute').
resolveDependencies()
Resolve a full list of Angular dependencies.
public
resolveDependencies(array<string|int, mixed> $names) : array<string|int, mixed>
Parameters
- $names : array<string|int, mixed>
-
List of Angular modules. Ex: array('crmMailing').
Tags
Return values
array<string|int, mixed> —List of Angular modules, include all dependencies. Ex: array('crmMailing', 'crmUi', 'crmUtil', 'ngRoute').
resolvePatterns()
Convert any globs in an Angular module to file names.
protected
resolvePatterns(array<string|int, mixed> $modules) : array<string|int, mixed>
Parameters
- $modules : array<string|int, mixed>
-
List of Angular modules.
Return values
array<string|int, mixed> —Updated list of Angular modules