Documentation

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
copyright

CiviCRM LLC https://civicrm.org/licensing

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

$cacheKey

protected mixed $cacheKey

$civicrmPath

protected mixed $civicrmPath

$civicrmUrl

protected mixed $civicrmUrl

$moduleExtensions

protected array<string|int, mixed> $moduleExtensions = \NULL

$upgraders

protected array<string|int, mixed> $upgraders = []

Array(string $extKey => CRM_Extension_Upgrader_Interface $upgrader)

Methods

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
throws
CRM_Extension_Exception_MissingException
Return values
array<string|int, mixed>

(string $extKey => string $baseUrl)

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
todo

consider multiple templates, support for one template for now

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

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
todo

We should improve this to return more appropriate text. eg. when an extension is not installed it should not say "version xx is installed".

Return values
string

isActiveModule()

public isActiveModule(string $name) : bool
Parameters
$name : string
Return values
bool

isExtensionClass()

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

keyToPath()

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
throws
CRM_Extension_Exception_MissingException
Return values
string

url for resources in this extension

refresh()

public refresh() : mixed

        
On this page

Search results