Documentation

CRM_Core_Resources_CollectionTrait

Class CRM_Core_Resources_CollectionTrait

This is a building-block for creating classes which maintain a list of resources. It implements of the CollectionInterface.

Tags
see
CRM_Core_Resources_CollectionInterface

Table of Contents

Properties

$defaults  : array<string|int, mixed>
Static defaults - a list of options to apply to any new snippets.
$isSorted  : bool
Whether the snippets array has been sorted
$snippets  : array<string|int, mixed>
List of snippets to inject within region.
$types  : array<string|int, mixed>
Whitelist of supported types.

Methods

_cmpSnippet()  : int
add()  : array<string|int, mixed>
Add an item to the collection.
addBundle()  : static
Assimilate all the resources listed in a bundle.
clear()  : static
Remove all snippets.
filter()  : static
Alter the contents of the collection.
find()  : iterable<string|int, mixed>
Find all snippets which match the given criterion.
findCreateSettingSnippet()  : array<string|int, mixed>
get()  : array<string|int, mixed>|null
Get snippet.
getAll()  : iterable<string|int, mixed>
Get a list of all snippets in this collection.
getSettings()  : array<string|int, mixed>
Get a fully-formed/altered list of settings, including the results of any callbacks/listeners.
merge()  : static
Assimilate a list of resources into this list.
update()  : static
Update specific properties of a snippet.
nextId()  : mixed
resolveName()  : mixed
sort()  : static
Ensure that the collection is sorted.

Properties

$defaults

Static defaults - a list of options to apply to any new snippets.

protected array<string|int, mixed> $defaults = ['weight' => 1, 'disabled' => \FALSE]

$isSorted

Whether the snippets array has been sorted

protected bool $isSorted = \TRUE

$snippets

List of snippets to inject within region.

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

e.g. $this->_snippets[3]['type'] = 'template';

$types

Whitelist of supported types.

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

Methods

_cmpSnippet()

public static _cmpSnippet(mixed $a, mixed $b) : int
Parameters
$a : mixed
$b : mixed
Return values
int

addBundle()

Assimilate all the resources listed in a bundle.

public addBundle(iterable<string|int, mixed>|string|CRM_Core_Resources_Bundle $bundle) : static
Parameters
$bundle : iterable<string|int, mixed>|string|CRM_Core_Resources_Bundle

Either bundle object, or the symbolic name of a bundle. Note: For symbolic names, the bundle must be a container service ('bundle.FOO').

Return values
static

filter()

Alter the contents of the collection.

public filter(callable $callback) : static
Parameters
$callback : callable

The callback is invoked once for each member in the collection. The callback may return one of three values:

  • TRUE: The item is OK and belongs in the collection.
  • FALSE: The item is not OK and should be omitted from the collection.
  • Array: The item should be revised (using the returned value).
Tags
see
CRM_Core_Resources_CollectionInterface::filter()
Return values
static

find()

Find all snippets which match the given criterion.

public find(callable $callback) : iterable<string|int, mixed>
Parameters
$callback : callable

The callback is invoked once for each member in the collection. The callback may return one of three values:

  • TRUE: The item is OK and belongs in the collection.
  • FALSE: The item is not OK and should be omitted from the collection.
Tags
see
CRM_Core_Resources_CollectionInterface::find()
Return values
iterable<string|int, mixed>

List of matching snippets.

findCreateSettingSnippet()

public & findCreateSettingSnippet([mixed $options = [] ]) : array<string|int, mixed>
Parameters
$options : mixed = []
Return values
array<string|int, mixed>

getSettings()

Get a fully-formed/altered list of settings, including the results of any callbacks/listeners.

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

update()

Update specific properties of a snippet.

public update(string $name, array<string|int, mixed> $snippet) : static
Parameters
$name : string

Symbolic of the resource/snippet to update.

$snippet : array<string|int, mixed>

Resource options. See CollectionInterface docs.

Tags
see
CRM_Core_Resources_CollectionInterface::update()
Return values
static

resolveName()

protected resolveName(string $name) : mixed
Parameters
$name : string

Name or alias. return array List of real names.

sort()

Ensure that the collection is sorted.

protected sort() : static
Return values
static

        
On this page

Search results