CRM_Extension_Mapper
in package
This class proivdes various helper functions for locating extensions data. It's designed for compatibility with pre-existing functions from CRM_Core_Extensions.
Most of these helper functions originate with the first major iteration of extensions -- a time when every extension had one eponymous PHP class, when there was no PHP class-loader, and when there was special-case logic sprinkled around to handle loading of "extension classes".
With module-extensions (Civi 4.2+), there are no eponymous classes -- instead, module-extensions follow the same class-naming and class-loading practices as core (and don't require special-case logic for class loading). Consequently, the helpers in here aren't much used with module-extensions.
Tags
Table of Contents
Constants
- EXT_TEMPLATES_DIRNAME = 'templates'
- Extension info file name.
Properties
- $cache : CRM_Utils_Cache_Interface
- $cacheKey : mixed
- $civicrmPath : mixed
- $civicrmUrl : mixed
- $container : CRM_Extension_Container_Interface
- $infos : array<string|int, CRM_Extension_Info>
- $moduleExtensions : array<string|int, mixed>
- $upgraders : array<string|int, mixed>
Methods
- __construct() : mixed
- classToKey() : string
- Given the class, provides extension's key.
- classToPath() : string
- Given the class, provides extension path.
- getActiveModuleFiles() : array<string|int, mixed>
- Fetch the list of active extensions of type 'module'
- getActiveModuleUrls() : array<string|int, mixed>
- Get a list of base URLs for all active modules.
- getAllInfos() : array<string|int, CRM_Extension_Info>
- getAllTags() : array<string|int, mixed>
- Get a list of extension tags.
- getKeysByPath() : array<string|int, mixed>
- Get a list of extension keys, filtered by the corresponding file path.
- getKeysByTag() : array<string|int, mixed>
- Get a list of extensions which match a given tag.
- getModules() : array<string|int, CRM_Core_Module>
- Get a list of all installed modules, including enabled and disabled ones
- getTemplateName() : string
- Given the class, provides the template name.
- getTemplatePath() : string
- Given the class, provides the template path.
- getUpgradeLink() : string
- This returns a formatted string containing an extension upgrade link for the UI.
- getUpgrader() : CRM_Extension_Upgrader_Interface
- isActiveModule() : bool
- isExtensionClass() : bool
- Given the string, returns true or false if it's an extension class name.
- isExtensionKey() : bool
- Given the string, returns true or false if it's an extension key.
- keyToBasePath() : string
- Given the key, provides the path to file containing extension's main class.
- keyToClass() : string
- Given the key, provides extension's class name.
- keyToInfo() : CRM_Extension_Info
- keyToPath() : string
- Given the key, provides the path to file containing extension's main class.
- keyToUrl() : string
- Given the key, provides the path to file containing extension's main class.
- refresh() : mixed
Constants
EXT_TEMPLATES_DIRNAME
Extension info file name.
public
mixed
EXT_TEMPLATES_DIRNAME
= 'templates'
Properties
$cache
protected
CRM_Utils_Cache_Interface
$cache
$cacheKey
protected
mixed
$cacheKey
$civicrmPath
protected
mixed
$civicrmPath
$civicrmUrl
protected
mixed
$civicrmUrl
$container
protected
CRM_Extension_Container_Interface
$container
$infos
protected
array<string|int, CRM_Extension_Info>
$infos
= []
(key => CRM_Extension_Info)
$moduleExtensions
protected
array<string|int, mixed>
$moduleExtensions
= \NULL
$upgraders
protected
array<string|int, mixed>
$upgraders
= []
Array(string $extKey => CRM_Extension_Upgrader_Interface $upgrader)
Methods
__construct()
public
__construct(CRM_Extension_Container_Interface|null $container[, CRM_Utils_Cache_Interface|null $cache = NULL ][, null $cacheKey = NULL ][, null $civicrmPath = NULL ][, null $civicrmUrl = NULL ]) : mixed
Parameters
- $container : CRM_Extension_Container_Interface|null
- $cache : CRM_Utils_Cache_Interface|null = NULL
- $cacheKey : null = NULL
- $civicrmPath : null = NULL
- $civicrmUrl : null = NULL
classToKey()
Given the class, provides extension's key.
public
classToKey(string $clazz) : string
Parameters
- $clazz : string
-
Extension class name.
Return values
string —name of extension key
classToPath()
Given the class, provides extension path.
public
classToPath(string $clazz) : string
Parameters
- $clazz : string
Return values
string —full path the extension .php file
getActiveModuleFiles()
Fetch the list of active extensions of type 'module'
public
getActiveModuleFiles([bool $fresh = FALSE ]) : array<string|int, mixed>
Parameters
- $fresh : bool = FALSE
-
whether to forcibly reload extensions list from canonical store.
Return values
array<string|int, mixed> —array(array('prefix' => $, 'fullName' => $, 'filePath' => $))
getActiveModuleUrls()
Get a list of base URLs for all active modules.
public
getActiveModuleUrls() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —(string $extKey => string $baseUrl)
getAllInfos()
public
getAllInfos() : array<string|int, CRM_Extension_Info>
Tags
Return values
array<string|int, CRM_Extension_Info> —Ex: $result['org.civicrm.foobar'] = new CRM_Extension_Info(...).
getAllTags()
Get a list of extension tags.
public
getAllTags() : array<string|int, mixed>
Return values
array<string|int, mixed> —Ex: ['form-building' => ['org.civicrm.afform-gui', 'org.civicrm.afform-html']]
getKeysByPath()
Get a list of extension keys, filtered by the corresponding file path.
public
getKeysByPath(string $pattern) : array<string|int, mixed>
Parameters
- $pattern : string
-
A file path. To search subdirectories, append "". Ex: "/var/www/extensions/" Ex: "/var/www/extensions/org.foo.bar"
Return values
array<string|int, mixed> —Array(string $key). Ex: array("org.foo.bar").
getKeysByTag()
Get a list of extensions which match a given tag.
public
getKeysByTag(string $tag) : array<string|int, mixed>
Parameters
- $tag : string
-
Ex: 'foo'
Return values
array<string|int, mixed> —Array(string $key). Ex: array("org.foo.bar").
getModules()
Get a list of all installed modules, including enabled and disabled ones
public
getModules() : array<string|int, CRM_Core_Module>
Return values
array<string|int, CRM_Core_Module>getTemplateName()
Given the class, provides the template name.
public
getTemplateName(string $clazz) : string
Parameters
- $clazz : string
-
Extension class name.
Tags
Return values
string —extension's template name
getTemplatePath()
Given the class, provides the template path.
public
getTemplatePath(string $clazz) : string
Parameters
- $clazz : string
-
Extension class name.
Return values
string —path to extension's templates directory
getUpgradeLink()
This returns a formatted string containing an extension upgrade link for the UI.
public
getUpgradeLink(CRM_Extension_Info $remoteExtensionInfo, array<string|int, mixed> $localExtensionInfo) : string
Parameters
- $remoteExtensionInfo : CRM_Extension_Info
- $localExtensionInfo : array<string|int, mixed>
Tags
Return values
stringgetUpgrader()
public
getUpgrader(string $key) : CRM_Extension_Upgrader_Interface
Parameters
- $key : string
-
Long name of the extension. Ex: 'org.example.myext'
Return values
CRM_Extension_Upgrader_InterfaceisActiveModule()
public
isActiveModule(string $name) : bool
Parameters
- $name : string
Return values
boolisExtensionClass()
Given the string, returns true or false if it's an extension class name.
public
isExtensionClass(string $clazz) : bool
Parameters
- $clazz : string
-
A string which might be an extension class name.
Return values
bool —true if given string is an extension class name
isExtensionKey()
Given the string, returns true or false if it's an extension key.
public
isExtensionKey(string $key) : bool
Parameters
- $key : string
-
A string which might be an extension key.
Return values
bool —true if given string is an extension name
keyToBasePath()
Given the key, provides the path to file containing extension's main class.
public
keyToBasePath(string $key) : string
Parameters
- $key : string
-
Extension key.
Return values
string —local path of the extension source tree
keyToClass()
Given the key, provides extension's class name.
public
keyToClass(string $key) : string
Parameters
- $key : string
-
Extension key.
Return values
string —name of extension's main class
keyToInfo()
public
keyToInfo(string $key[, bool $fresh = FALSE ]) : CRM_Extension_Info
Parameters
- $key : string
-
Extension fully-qualified-name.
- $fresh : bool = FALSE
Tags
Return values
CRM_Extension_InfokeyToPath()
Given the key, provides the path to file containing extension's main class.
public
keyToPath(string $key) : string
Parameters
- $key : string
-
Extension key.
Return values
string —path to file containing extension's main class
keyToUrl()
Given the key, provides the path to file containing extension's main class.
public
keyToUrl(string $key) : string
Parameters
- $key : string
-
Extension key.
Tags
Return values
string —url for resources in this extension
refresh()
public
refresh() : mixed