Documentation

LgmsGuideOwnerBlock extends BlockBase
in package

Provides a 'LGMS Author Information' Block.

This block displays the guide owner's contact information including their name, email, phone number, profile picture, and any associated subjects.

Tags
Block

( id = "lgms_guide_owner_block", admin_label = @Translation("LGMS Author Information"), category = @Translation("LGMS") )

Table of Contents

Methods

blockForm()  : array<string|int, mixed>
{@inheritdoc}
blockSubmit()  : void
{@inheritdoc}
build()  : array<string|int, mixed>
Builds the block content.
defaultConfiguration()  : array<string|int, mixed>
{@inheritdoc}
getCacheMaxAge()  : int
{@inheritdoc}
formatPhoneNumber()  : string
Formats a raw phone number into a more readable format.
makePhoneNumberClickable()  : string
Converts a phone number into a clickable link format.
addEditProfileLink()  : array<string|int, mixed>
Adds a link for users to edit their profile.
fetchSubjectsMarkup()  : string
Fetches and constructs markup for the subjects associated with the user.

Methods

blockForm()

{@inheritdoc}

public blockForm(mixed $form, FormStateInterface $form_state) : array<string|int, mixed>
Parameters
$form : mixed
$form_state : FormStateInterface
Return values
array<string|int, mixed>

blockSubmit()

{@inheritdoc}

public blockSubmit(mixed $form, FormStateInterface $form_state) : void
Parameters
$form : mixed
$form_state : FormStateInterface

build()

Builds the block content.

public build() : array<string|int, mixed>

Fetches and displays author information based on the node context. The displayed information includes name, profile picture, email, phone number, and subjects associated with the guide's owner.

Return values
array<string|int, mixed>

A renderable array representing the block content.

defaultConfiguration()

{@inheritdoc}

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

formatPhoneNumber()

Formats a raw phone number into a more readable format.

protected formatPhoneNumber(string $phone_number_raw) : string
Parameters
$phone_number_raw : string

The unformatted phone number string.

Return values
string

The formatted phone number.

makePhoneNumberClickable()

Converts a phone number into a clickable link format.

protected makePhoneNumberClickable(string $phone_number_raw, string $phone_number_formatted) : string
Parameters
$phone_number_raw : string

The unformatted phone number string.

$phone_number_formatted : string

The phone number formatted for display.

Return values
string

A string containing an HTML anchor tag with the href set to a tel: URI.

Adds a link for users to edit their profile.

private addEditProfileLink() : array<string|int, mixed>

This method generates a link to the user profile edit form. It's shown to the owner of the guide, allowing them to directly access and edit their profile information.

Return values
array<string|int, mixed>

A render array for the edit profile link.

fetchSubjectsMarkup()

Fetches and constructs markup for the subjects associated with the user.

private fetchSubjectsMarkup(User $owner) : string
Parameters
$owner : User

The user entity whose subjects are to be fetched.

Return values
string

The constructed HTML markup containing the list of subjects.


        
On this page

Search results