Documentation

CRM_Afform_AfformScanner extends AutoService
in package

Class CRM_Afform_AfformScanner

The AfformScanner searches the ang directory of extensions and civicrm.files for files named *.aff.*. Each item is interpreted as a form instance.

To reduce file-scanning, we keep a cache of file paths.

Tags
service

afform_scanner

Table of Contents

Constants

DEFAULT_REQUIRES  = 'afCore'
FILE_REGEXP  = '/\.aff\.(json|html|php)$/'
LAYOUT_FILE  = 'aff.html'
METADATA_JSON  = 'aff.json'
METADATA_PHP  = 'aff.php'

Properties

$cache  : CRM_Utils_Cache_Interface

Methods

__construct()  : mixed
CRM_Afform_AfformScanner constructor.
addComputedFields()  : mixed
Adds base_module, has_local & has_base to an afform metadata record
clear()  : void
createSiteLocalPath()  : string
Determine the path where we can write our own customized/overridden version of a file.
findFilePath()  : string|null
Get the absolute path to the given file.
findFilePaths()  : array<string|int, mixed>
Get a list of all forms and their file paths.
getLayout()  : mixed
getMeta()  : array<string|int, mixed>|null
Get metadata and optionally the layout for a file-based Afform.
getMetas()  : array<string|int, mixed>
Get the effective metadata for all file-based forms.
getSiteLocalPath()  : string
Get the path where site-local form customizations are stored.
appendFilePaths()  : mixed
isUseCachedPaths()  : bool
Is the cache to be used.

Constants

FILE_REGEXP

public mixed FILE_REGEXP = '/\.aff\.(json|html|php)$/'

Properties

Methods

addComputedFields()

Adds base_module, has_local & has_base to an afform metadata record

public addComputedFields(array<string|int, mixed> &$record) : mixed
Parameters
$record : array<string|int, mixed>

createSiteLocalPath()

Determine the path where we can write our own customized/overridden version of a file.

public createSiteLocalPath(string $formName, string $fileType) : string
Parameters
$formName : string

Ex: 'afformViewIndividual'

$fileType : string

Ex: 'aff.json'

Return values
string

Ex: '/var/www/sites/default/files/civicrm/afform/afformViewIndividual.aff.json'

findFilePath()

Get the absolute path to the given file.

public findFilePath(string $formName, string $suffix) : string|null
Parameters
$formName : string

Ex: 'afformViewIndividual'

$suffix : string

Ex: 'aff.json'

Return values
string|null

Ex: '/var/www/sites/default/files/civicrm/ang/afform/afformViewIndividual.aff.json'

findFilePaths()

Get a list of all forms and their file paths.

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

Ex: ['afformViewIndividual' => ['/var/www/foo/ang/afformViewIndividual']]

getLayout()

public getLayout(mixed $formName) : mixed

unused function

Parameters
$formName : mixed

getMeta()

Get metadata and optionally the layout for a file-based Afform.

public getMeta(string $name[, bool $getLayout = FALSE ]) : array<string|int, mixed>|null
Parameters
$name : string

Ex: 'afformViewIndividual'

$getLayout : bool = FALSE

Whether to fetch 'layout' from the related html file.

Tags
see
Afform::getFields
Return values
array<string|int, mixed>|null

An array with some mix of the keys supported by getFields

getMetas()

Get the effective metadata for all file-based forms.

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

A list of all forms, keyed by form name. NOTE: This is only data available in *.aff.(json|php) files. It does NOT include layout. Ex: ['afformViewIndividual' => ['title' => 'View an individual contact', ...]]

getSiteLocalPath()

Get the path where site-local form customizations are stored.

public getSiteLocalPath() : string
Return values
string

Ex: '/var/www/sites/default/files/civicrm/afform'.

appendFilePaths()

private appendFilePaths(array<string|int, array<string|int, mixed>> &$formPaths, string $parent, string $module) : mixed
Parameters
$formPaths : array<string|int, array<string|int, mixed>>

List of all form paths. Ex: ['foo' => [0 => '/var/www/org.example.foobar/ang']]

$parent : string

Ex: '/var/www/org.example.foobar/afform/'

$module : string

Name of module or '' empty string for local files.

isUseCachedPaths()

Is the cache to be used.

private isUseCachedPaths() : bool

Skipping the cache helps developers moving files around & messes with developers debugging performance. It's a cruel world.

FIXME: Use a separate setting. Maybe use the asset-builder cache setting?

Return values
bool

        
On this page

Search results