Skip to content

RepositoryFileData

Shows a value from a JSON or YAML file in the repository.


Methods

defaultSettings

{@inheritdoc}

public static defaultSettings(): array
  • This method is static.

settingsForm

{@inheritdoc}

public settingsForm(array $form, \Drupal\Core\Form\FormStateInterface $form_state): array

Parameters:

Parameter Type Description
$form array
$form_state \Drupal\Core\Form\FormStateInterface

settingsSummary

{@inheritdoc}

public settingsSummary(): array

getValue

Gets the value to show.

protected getValue(string $host, string $repository): mixed

Parameters:

Parameter Type Description
$host string
The repository's host.
$repository string
The repository's path on the host, such as owner/name.

Return Value:

The value.


viewItem

Builds the output for one repository.

protected viewItem(string $host, string $repository): array

Parameters:

Parameter Type Description
$host string
The repository's host, such as github.com.
$repository string
The repository's path on the host, such as owner/name.

Return Value:

A render array.


Inherited methods

create

{@inheritdoc}

public static create(\Symfony\Component\DependencyInjection\ContainerInterface $container, array $configuration, mixed $plugin_id, mixed $plugin_definition): static
  • This method is static. Parameters:
Parameter Type Description
$container \Symfony\Component\DependencyInjection\ContainerInterface
$configuration array
$plugin_id mixed
$plugin_definition mixed

getSupportedProviders

Gets the providers this formatter works with.

protected getSupportedProviders(): string[]

Return Value:

Git provider plugin IDs, or an empty array for every provider.


viewItem

Builds the output for one repository.

protected viewItem(string $host, string $repository): array
  • This method is abstract. Parameters:
Parameter Type Description
$host string
The repository's host, such as github.com.
$repository string
The repository's path on the host, such as owner/name.

Return Value:

A render array.

Throws:

If the data can't be read. The base class shows the error instead. - Exception


viewElements

{@inheritdoc}

public viewElements(\Drupal\Core\Field\FieldItemListInterface $items, mixed $langcode): array

Parameters:

Parameter Type Description
$items \Drupal\Core\Field\FieldItemListInterface
$langcode mixed

view

{@inheritdoc}

public view(\Drupal\Core\Field\FieldItemListInterface $items, mixed $langcode = null): array

Parameters:

Parameter Type Description
$items \Drupal\Core\Field\FieldItemListInterface
$langcode mixed

errorElement

Builds the output for an error from a host's API.

protected errorElement(\Throwable $exception): array

Parameters:

Parameter Type Description
$exception \Throwable
The exception from the request or from reading its data.

Return Value:

A render array with the host's error message, as plain text.


getFileData

Gets the data of a JSON or YAML file in a repository.

protected getFileData(string $host, string $repository, string $path, string $ref = ''): array

Parameters:

Parameter Type Description
$host string
The repository's host.
$repository string
The repository's path on the host, such as owner/name.
$path string
The file's path in the repository.
$ref string
(optional) A branch, tag or commit. Defaults to the default branch.

Return Value:

The file's data.