bim_gdpr-1.0.0-rc3/src/Plugin/bim_gdpr/BimGdprServiceType/GoogleTagManagerBimGdprServiceType.php

src/Plugin/bim_gdpr/BimGdprServiceType/GoogleTagManagerBimGdprServiceType.php
<?php

namespace Drupal\bim_gdpr\Plugin\bim_gdpr\BimGdprServiceType;

use Drupal\bim_gdpr\BimGdprServiceInterface;
use Drupal\bim_gdpr\PluginManager\BimGdprServiceType\AbstractBimGdprServiceType;
use Drupal\bim_gdpr\PluginManager\BimGdprServiceType\BimGdprServiceTypeInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Plugin implementation For the type processor.
 *
 * @BimGdprServiceTypeAnnotation(
 *   id = "google_tag_manager",
 *   label = "Google Tag Manager"
 * )
 */
class GoogleTagManagerBimGdprServiceType extends AbstractBimGdprServiceType implements BimGdprServiceTypeInterface {

  use StringTranslationTrait;

  /**
   * GoogleTagManager constructor.
   */
  public function __construct() {
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container): BimGdprServiceTypeInterface {
    return new static();
  }

  /**
   * {@inheritdoc}
   */
  public function getConfigForm(BimGdprServiceInterface $service, array $parentForm, FormStateInterface $formState, array $requiredStates = []): array {
    $data = $service->getData();
    $form = [];
    $form['gtm_id'] = [
      '#type'          => 'textfield',
      '#title'         => $this->t('The GTM Id.'),
      '#default_value' => isset($data['gtm_id']) ? $data['gtm_id'] : '',
      '#states'        => $requiredStates,
    ];

    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function getMassagedConfigFormValue(array $values, array $form, FormStateInterface $formState): array {
    return $values;
  }

  /**
   * {@inheritdoc}
   */
  public function alterSettingsBeforeApply(array &$settings) {
  }

  /**
   * {@inheritdoc}
   */
  public function getLibraries(): array {
    return ['bim_gdpr/services.google_tag_manager'];
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc