Documentation

ImportMap extends AutoService
in package
implements HookInterface

ECMAScript Modules (ESMs) allow you to load a JS file based on a physical-path or a logical-path. Compare:

  • import { TableWidget } from 'https://example.com/sites/all/modules/civicrm/js/table-widget.js';
  • import { TableWidget } from 'civicrm/js/tab-widget.js';

The purpose of Civi\Esm\ImportMap (aka esm.import_map) is to build a list of all the logical prefixes supported by civicrm-core and CiviCRM extensions.

This is generally consumed by BrowserLoader or a similar class. For a fuller description of this mechanism, see the neighboring README.

Tags
see
BrowserLoader
see

./README.md

service

esm.import_map

Table of Contents

Interfaces

HookInterface
Interface HookInterface

Properties

$prefixes  : array<string|int, mixed>|null

Methods

addPrefix()  : $this
getPrefixes()  : array<string|int, mixed>
hook_civicrm_esmImportMap()  : void
Register default mappings on behalf of civicrm-core.
load()  : $this
Load the list of imports, as declared by CiviCRM and its extensions.

Properties

$prefixes

protected array<string|int, mixed>|null $prefixes = NULL

Ex: [['prefix' => 'lodash/', 'ext' => 'civicrm', 'relPath' => 'bower_components/lodash/']]

Methods

addPrefix()

public addPrefix(string $prefix, string $ext[, string $relPath = '' ]) : $this
Parameters
$prefix : string
$ext : string

Ex: 'civicrm', 'org.example.foobar'

$relPath : string = ''

Relative path within $ext. Ex: '/', '/packages/foo-1.2.3/'

Tags
see
CRM_Core_Resources::getUrl()
see
CRM_Core_Resources::getPath()
Return values
$this

getPrefixes()

public getPrefixes() : array<string|int, mixed>
Return values
array<string|int, mixed>

hook_civicrm_esmImportMap()

Register default mappings on behalf of civicrm-core.

public hook_civicrm_esmImportMap(ImportMap $importMap) : void
Parameters
$importMap : ImportMap

load()

Load the list of imports, as declared by CiviCRM and its extensions.

protected load() : $this
Return values
$this

        
On this page

Search results