Documentation

helperFunction
in package

Provides helper functions for the LGMS module.

This class contains methods to assist with common tasks such as generating links, building accordion structures, fetching blocks, and querying the database. It serves as a utility class for the module, centralizing functionality needed across multiple controllers.

Table of Contents

Properties

$database  : Connection
The database connection.

Methods

__construct()  : mixed
Constructs a new helperFunction object.
buildAccordion()  : array<string|int, mixed>
Builds an accordion structure from the provided data.
getFromTable()  : array<string|int, mixed>
Fetches records from a specified table and returns them as an array.
getLGMSSearchBar()  : array<string|int, mixed>
Retrieves and prepares a block for rendering based on the given block ID and type.
getLink()  : string
Generates a fully qualified URL for a given node ID.

Properties

$database

The database connection.

protected Connection $database

Methods

__construct()

Constructs a new helperFunction object.

public __construct(Connection $database) : mixed
Parameters
$database : Connection

The database connection.

buildAccordion()

Builds an accordion structure from the provided data.

public buildAccordion(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed>

An associative array where keys are accordion titles and values are arrays of items containing 'text' and 'markup' to display inside each accordion.

Return values
array<string|int, mixed>

A render array representing an accordion structure.

getFromTable()

Fetches records from a specified table and returns them as an array.

public getFromTable(string $tableName) : array<string|int, mixed>
Parameters
$tableName : string

The table name to query.

Return values
array<string|int, mixed>

An array of objects representing the fetched records.

getLGMSSearchBar()

Retrieves and prepares a block for rendering based on the given block ID and type.

public getLGMSSearchBar(string $blockID, string $type) : array<string|int, mixed>
Parameters
$blockID : string

The block plugin ID.

$type : string

The block type.

Return values
array<string|int, mixed>

A render array for the block if the current user has access; otherwise, an empty array.

Generates a fully qualified URL for a given node ID.

public getLink(string $nid) : string
Parameters
$nid : string

The node ID.

Return values
string

The fully qualified URL to the node.


        
On this page

Search results