Skip to content

ServicePluginBase

Defines a base implementation for analytics service plugins will extend.


Properties

hasMultiple

Whether more than one analytics service uses this plugin.

protected bool|null $hasMultiple

adminContext

The admin context.

protected \Drupal\Core\Routing\AdminContext $adminContext

currentUser

The current user.

protected \Drupal\Core\Session\AccountInterface $currentUser

entityTypeManager

The entity type manager.

protected \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager

enableBypassPermission

Whether the 'bypass all analytics services' permission skips tracking.

protected bool $enableBypassPermission

Set from the analytics.enable_bypass_permission container parameter.


serviceId

The ID of the service config entity using this plugin.

protected string $serviceId

Methods

setServiceId

Sets the current service config entity ID that is using this plugin.

public setServiceId(mixed $service_id): mixed

Parameters:

Parameter Type Description
$service_id mixed
The service config entity ID.

getServiceId

Gets the current service config entity ID that is using this plugin.

public getServiceId(): string

Return Value:

The service config entity ID.


__construct

{@inheritdoc}

public __construct(array $configuration, mixed $plugin_id, mixed $plugin_definition): mixed

Parameters:

Parameter Type Description
$configuration array
$plugin_id mixed
$plugin_definition mixed

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

getLabel

Returns the label of the analytics service.

public getLabel(): string

Return Value:

The label of this analytics service.


access

{@inheritdoc}

public access(mixed $operation, ?\Drupal\Core\Session\AccountInterface $account = null, mixed $return_as_object = false): mixed

Parameters:

Parameter Type Description
$operation mixed
$account ?\Drupal\Core\Session\AccountInterface
$return_as_object mixed

hasMultipleInstances

Checks whether more than one analytics service uses this plugin.

public hasMultipleInstances(): bool

Return Value:

TRUE if two or more analytics services use this plugin.


getOutput

Returns the output of the analytics service.

public getOutput(): array

Return Value:

A structured, renderable array.


getCspSources

Gets the Content Security Policy sources the service's output needs.

public getCspSources(): array<string,string[]>

Return Value:

URLs keyed by directive, such as ['script-src' => ['https://gc.zgo.at']].


getCacheableUrls

Gets the URLs of the service's external files to cache locally.

public getCacheableUrls(): array

Return Value:

A list of URLs.


getCacheContexts

{@inheritdoc}

public getCacheContexts(): array

The output's cacheability. Plugins that vary their output by something other than their configuration add it here.


getCacheTags

{@inheritdoc}

public getCacheTags(): array

getCacheMaxAge

{@inheritdoc}

public getCacheMaxAge(): int

setConfiguration

{@inheritdoc}

public setConfiguration(array $configuration): mixed

Parameters:

Parameter Type Description
$configuration array

getConfiguration

{@inheritdoc}

public getConfiguration(): array

defaultConfiguration

{@inheritdoc}

public defaultConfiguration(): array

buildConfigurationForm

{@inheritdoc}

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

Parameters:

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

validateConfigurationForm

{@inheritdoc}

public validateConfigurationForm(array& $form, \Drupal\Core\Form\FormStateInterface $form_state): mixed

Parameters:

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

submitConfigurationForm

{@inheritdoc}

public submitConfigurationForm(array& $form, \Drupal\Core\Form\FormStateInterface $form_state): mixed

Parameters:

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

calculateDependencies

{@inheritdoc}

public calculateDependencies(): array