You are here

class Container in GoogleTagManager 8

Defines the container configuration entity.

@ConfigEntityType( id = "google_tag_container", label = @Translation("Container"), label_singular = @Translation("container"), label_plural = @Translation("containers"), label_collection = @Translation("Containers"), handlers = { "storage" = "Drupal\Core\Config\Entity\ConfigEntityStorage", "list_builder" = "Drupal\google_tag\ContainerListBuilder", "form" = { "default" = "Drupal\google_tag\Form\ContainerForm", "delete" = "Drupal\Core\Entity\EntityDeleteForm" }, "access" = "Drupal\google_tag\ContainerAccessControlHandler" }, admin_permission = "administer google tag manager", config_prefix = "container", entity_keys = { "id" = "id", "label" = "label", "status" = "status" }, config_export = { "id", "label", "weight", "container_id", "data_layer", "include_classes", "whitelist_classes", "blacklist_classes", "include_environment", "environment_id", "environment_token", "path_toggle", "path_list", "role_toggle", "role_list", "status_toggle", "status_list", "conditions", }, links = { "add-form" = "/admin/config/system/google-tag/add", "edit-form" = "/admin/config/system/google-tag/manage/{google_tag_container}", "delete-form" = "/admin/config/system/google-tag/manage/{google_tag_container}/delete", "enable" = "/admin/config/system/google-tag/manage/{google_tag_container}/enable", "disable" = "/admin/config/system/google-tag/manage/{google_tag_container}/disable", "collection" = "/admin/config/system/google-tag", } )

@todo Add a clone operation. this may not be an option in above annotation "clone-form" = "/admin/structure/google_tag/manage/{google_tag_container}/clone",

Hierarchy

Expanded class hierarchy of Container

3 files declare their use of Container
ContainerController.php in src/ContainerController.php
google_tag.api.php in ./google_tag.api.php
Hooks provided by this module.
GTMTestBase.php in tests/src/Functional/GTMTestBase.php

File

src/Entity/Container.php, line 71

Namespace

Drupal\google_tag\Entity
View source
class Container extends ConfigEntityBase implements ConfigEntityInterface, EntityWithPluginCollectionInterface {
  use StringTranslationTrait;

  /**
   * The machine name for the configuration entity.
   *
   * @var string
   */
  protected $id;

  /**
   * The human-readable name of the configuration entity.
   *
   * @var string
   */
  public $label;

  /**
   * The weight of the configuration entity.
   *
   * @var int
   */
  public $weight = 0;

  /**
   * The Google Tag Manager container id.
   *
   * @var string
   */
  public $container_id;

  /**
   * The name of the data layer.
   *
   * @var string
   */
  public $data_layer;

  /**
   * Whether to add the listed classes to the data layer.
   *
   * @var bool
   */
  public $include_classes;

  /**
   * The white-listed classes.
   *
   * @var string
   */
  public $whitelist_classes;

  /**
   * The black-listed classes.
   *
   * @var string
   */
  public $blacklist_classes;

  /**
   * Whether to include the environment items in the applicable snippets.
   *
   * @var bool
   */
  public $include_environment;

  /**
   * The environment ID.
   *
   * @var string
   */
  public $environment_id;

  /**
   * The environment token.
   *
   * @var string
   */
  public $environment_token;

  /**
   * Whether to include or exclude the listed paths.
   *
   * @var string
   */
  public $path_toggle;

  /**
   * The listed paths.
   *
   * @var string
   */
  public $path_list;

  /**
   * Whether to include or exclude the listed roles.
   *
   * @var string
   */
  public $role_toggle;

  /**
   * The listed roles.
   *
   * @var array
   */
  public $role_list;

  /**
   * Whether to include or exclude the listed statuses.
   *
   * @var string
   */
  public $status_toggle;

  /**
   * The listed statuses.
   *
   * @var string
   */
  public $status_list;

  /**
   * The insertion conditions.
   *
   * Each item is the configuration array not the condition object.
   *
   * @var array
   */
  protected $conditions = [];

  /**
   * The insertion condition collection.
   *
   * @var \Drupal\Core\Condition\ConditionPluginCollection
   */
  protected $conditionCollection;

  /**
   * The condition plugin manager.
   *
   * @var \Drupal\Core\Executable\ExecutableManagerInterface
   */
  protected $conditionPluginManager;

  /**
   * {@inheritdoc}
   */
  public function __construct(array $values, $entity_type) {
    parent::__construct($values, $entity_type);
    $values = array_diff_key($values, array_flip([
      'uuid',
      'langcode',
    ]));
    if (empty($values)) {

      // Initialize entity properties from default container settings.
      $config = \Drupal::config('google_tag.settings');
      foreach ($config
        ->get('_default_container') as $key => $value) {
        $this->{$key} = $value;
      }
    }
  }

  /**
   * Returns array of JavaScript snippets.
   *
   * @return array
   *   Associative array of snippets keyed by type: script, noscript and
   *   data_layer.
   */
  public function snippets() {
    $snippets = [
      'script' => $this
        ->scriptSnippet(),
      'noscript' => $this
        ->noscriptSnippet(),
      'data_layer' => $this
        ->dataLayerSnippet(),
    ];

    // Allow other modules to alter the snippets.
    \Drupal::moduleHandler()
      ->alter('google_tag_snippets', $snippets, $this);
    return $snippets;
  }

  /**
   * Returns JavaScript script snippet.
   *
   * @return array
   *   The script snippet.
   */
  protected function scriptSnippet() {

    // Gather data.
    $container_id = $this
      ->variableClean('container_id');
    $data_layer = $this
      ->variableClean('data_layer');
    $query = $this
      ->environmentQuery();

    // Build script snippet.
    $script = <<<EOS
(function(w,d,s,l,i){
  w[l]=w[l]||[];
  w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});
  var f=d.getElementsByTagName(s)[0];
  var j=d.createElement(s);
  var dl=l!='dataLayer'?'&l='+l:'';
  j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl+'{<span class="php-variable">$query</span>}';
  j.async=true;
  f.parentNode.insertBefore(j,f);
})(window,document,'script','{<span class="php-variable">$data_layer</span>}','{<span class="php-variable">$container_id</span>}');
EOS;
    return $this
      ->compactSnippet($script);
  }

  /**
   * Returns JavaScript noscript snippet.
   *
   * @return array
   *   The noscript snippet.
   */
  protected function noscriptSnippet() {

    // Gather data.
    $container_id = $this
      ->variableClean('container_id');
    $query = $this
      ->environmentQuery();

    // Build noscript snippet.
    $noscript = <<<EOS
<noscript aria-hidden="true"><iframe src="https://www.googletagmanager.com/ns.html?id={<span class="php-variable">$container_id</span>}{<span class="php-variable">$query</span>}"
 height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
EOS;
    return $this
      ->compactSnippet($noscript, [
      "\n",
    ]);
  }

  /**
   * Returns JavaScript data layer snippet or adds items to data layer.
   *
   * @return string|null
   *   The data layer snippet or NULL.
   */
  protected function dataLayerSnippet() {

    // Gather data.
    $data_layer = $this
      ->variableClean('data_layer');
    $whitelist = $this
      ->get('whitelist_classes');
    $blacklist = $this
      ->get('blacklist_classes');
    $classes = [];
    $names = [
      'whitelist',
      'blacklist',
    ];
    foreach ($names as $name) {
      if (empty(${$name})) {
        continue;
      }

      // @see https://www.drupal.org/files/issues/add_options_to-2851405-7.patch
      // this suggests to flip order of previous two statements; yet if user
      // enters a new line in textarea, then this change does not eliminate the
      // empty script item. Need to trim "\n" from ends of string.
      ${$name} = explode("\n", ${$name});
      $classes["gtm.{$name}"] = ${$name};
    }
    if ($classes) {

      // Build data layer snippet.
      $classes = json_encode($classes);
      $script = <<<EOS
(function(w,l){
  w[l]=w[l]||[];
  w[l].push({<span class="php-variable">$classes</span>});
})(window,'{<span class="php-variable">$data_layer</span>}');
EOS;
      return $this
        ->compactSnippet($script);
    }
  }

  /**
   * Returns a query string with the environment parameters.
   *
   * @return string
   *   The query string.
   */
  public function environmentQuery() {
    if (!$this
      ->get('include_environment')) {
      return '';
    }

    // Gather data.
    $environment_id = $this
      ->variableClean('environment_id');
    $environment_token = $this
      ->variableClean('environment_token');

    // Build query string.
    return "&gtm_auth={$environment_token}&gtm_preview={$environment_id}&gtm_cookies_win=x";
  }

  /**
   * Returns a cleansed variable.
   *
   * @param string $variable
   *   The variable name.
   *
   * @return string
   *   The cleansed variable.
   */
  public function variableClean($variable) {
    return trim(json_encode($this
      ->get($variable)), '"');
  }

  /**
   * Returns the compacted snippet.
   *
   * @param string $snippet
   *   The JavaScript snippet.
   * @param array $search
   *   The array of strings to replace with blank.
   *
   * @return string
   *   The compacted snippet.
   */
  protected function compactSnippet($snippet, array $search = [
    "\n",
    '  ',
  ]) {
    $compact = \Drupal::config('google_tag.settings')
      ->get('compact_snippet');
    return $compact ? str_replace($search, '', $snippet) : $snippet;
  }

  /**
   * Determines whether to insert the snippet on the response.
   *
   * @return bool
   *   TRUE if the conditions are met; FALSE otherwise.
   */
  public function insertSnippet() {
    static $satisfied = [];
    if (!isset($satisfied[$this->id])) {
      $id = $this
        ->get('container_id');
      if (empty($id)) {

        // No container ID.
        return $satisfied[$this->id] = FALSE;
      }
      $this
        ->displayMessage('google_tag container ' . $this->id);
      $satisfied[$this->id] = TRUE;
      if (!$this
        ->statusCheck() || !$this
        ->pathCheck() || !$this
        ->roleCheck() || !$this
        ->access('view')) {

        // Omit snippet if any condition is not met.
        $satisfied[$this->id] = FALSE;
      }

      // Allow other modules to alter the insertion criteria.
      \Drupal::moduleHandler()
        ->alter('google_tag_insert', $satisfied[$this->id], $this);
      $this
        ->displayMessage('after alter @satisfied', [
        '@satisfied' => $satisfied[$this->id],
      ]);
    }
    return $satisfied[$this->id];
  }

  /**
   * Determines whether to insert the snippet based on status code settings.
   *
   * @return bool
   *   TRUE if the status conditions are met; FALSE otherwise.
   */
  protected function statusCheck() {
    $toggle = $this
      ->get('status_toggle');
    $statuses = $this
      ->get('status_list');
    if (empty($statuses)) {
      $satisfied = $toggle == GOOGLE_TAG_EXCLUDE_LISTED;
    }
    else {

      // Get the HTTP response status.
      $request = \Drupal::request();
      $status = '200';
      if ($exception = $request->attributes
        ->get('exception')) {
        $status = $exception
          ->getStatusCode();
      }
      $satisfied = strpos($statuses, (string) $status) !== FALSE;
      $satisfied = $toggle == GOOGLE_TAG_EXCLUDE_LISTED ? !$satisfied : $satisfied;
    }
    $this
      ->displayMessage('status check @satisfied', [
      '@satisfied' => $satisfied,
    ]);
    return $satisfied;
  }

  /**
   * Determines whether to insert the snippet based on the path settings.
   *
   * @return bool
   *   TRUE if the path conditions are met; FALSE otherwise.
   */
  protected function pathCheck() {
    $toggle = $this
      ->get('path_toggle');
    $paths = mb_strtolower($this
      ->get('path_list'));
    if (empty($paths)) {
      $satisfied = $toggle == GOOGLE_TAG_EXCLUDE_LISTED;
    }
    else {
      $request = \Drupal::request();
      $current_path = \Drupal::service('path.current');
      $alias_manager = \Drupal::service('path_alias.manager');
      $path_matcher = \Drupal::service('path.matcher');

      // @todo Are not some paths case sensitive???
      // Compare the lowercase path alias (if any) and internal path.
      $path = $current_path
        ->getPath($request);
      $path_alias = mb_strtolower($alias_manager
        ->getAliasByPath($path));
      $satisfied = $path_matcher
        ->matchPath($path_alias, $paths) || $path != $path_alias && $path_matcher
        ->matchPath($path, $paths);
      $satisfied = $toggle == GOOGLE_TAG_EXCLUDE_LISTED ? !$satisfied : $satisfied;
    }
    $this
      ->displayMessage('path check @satisfied', [
      '@satisfied' => $satisfied,
    ]);
    return $satisfied;
  }

  /**
   * Determines whether to insert the snippet based on the user role settings.
   *
   * @return bool
   *   TRUE if the role conditions are met; FALSE otherwise.
   */
  protected function roleCheck() {
    $toggle = $this
      ->get('role_toggle');
    $roles = array_filter($this
      ->get('role_list'));
    if (empty($roles)) {
      $satisfied = $toggle == GOOGLE_TAG_EXCLUDE_LISTED;
    }
    else {
      $satisfied = FALSE;

      // Check user roles against listed roles.
      $satisfied = (bool) array_intersect($roles, \Drupal::currentUser()
        ->getRoles());
      $satisfied = $toggle == GOOGLE_TAG_EXCLUDE_LISTED ? !$satisfied : $satisfied;
    }
    $this
      ->displayMessage('role check @satisfied', [
      '@satisfied' => $satisfied,
    ]);
    return $satisfied;
  }

  /**
   * Displays a message.
   *
   * @param string $message
   *   The message to display.
   * @param array $args
   *   (optional) An associative array of replacements.
   */
  public function displayMessage($message, array $args = []) {
    if (\Drupal::config('google_tag.settings')
      ->get('debug_output')) {
      \Drupal::service('messenger')
        ->addStatus($this
        ->t($message, $args), TRUE);
    }
  }

  /**
   * Returns the snippet directory path.
   *
   * @return string
   *   The snippet directory path.
   */
  public function snippetDirectory() {
    return \Drupal::config('google_tag.settings')
      ->get('uri') . "/google_tag/{$this->id()}";
  }

  /**
   * Returns the snippet URI for a snippet type.
   *
   * @param string $type
   *   The snippet type.
   *
   * @return string
   *   The snippet URI.
   */
  public function snippetURI($type) {
    return $this
      ->snippetDirectory() . "/google_tag.{$type}.js";
  }

  /**
   * Returns the snippet cache ID for a snippet type.
   *
   * @param string $type
   *   The snippet type.
   *
   * @return string
   *   The snippet cache ID.
   */
  public function snippetCid($type) {
    return "google_tag:{$type}:{$this->id()}";
  }

  /**
   * Returns tag array for the snippet type.
   *
   * @param string $type
   *   The snippet type.
   * @param int $weight
   *   The weight of the item.
   *
   * @return array
   *   The tag array.
   */
  public function fileTag($type, $weight) {
    $uri = $this
      ->snippetURI($type);
    $url = file_url_transform_relative(file_create_url($uri));
    $query_string = \Drupal::state()
      ->get('system.css_js_query_string') ?: '0';
    $attachment = [
      [
        '#type' => 'html_tag',
        '#tag' => 'script',
        '#attributes' => [
          'src' => $url . '?' . $query_string,
          'defer' => TRUE,
        ],
        '#weight' => $weight,
      ],
      "google_tag_{$type}_tag__{$this->id()}",
    ];
    return $attachment;
  }

  /**
   * Returns tag array for the snippet type.
   *
   * @param string $type
   *   The snippet type.
   * @param int $weight
   *   The weight of the item.
   *
   * @return array
   *   The tag array.
   */
  public function inlineTag($type, $weight) {
    $contents = $this
      ->getSnippetContents($type);
    $attachment = [
      $contents ? [
        '#type' => 'html_tag',
        '#tag' => 'script',
        '#value' => new FormattableMarkup($contents, []),
        '#weight' => $weight,
      ] : [
        '#type' => 'ignore_tag',
      ],
      "google_tag_{$type}_tag__{$this->id()}",
    ];
    return $attachment;
  }

  /**
   * Returns tag array for the snippet type.
   *
   * @param string $type
   *   (optional) The snippet type.
   * @param int $weight
   *   (optional) The weight of the item.
   *
   * @return array
   *   The tag array.
   */
  public function noscriptTag($type = 'noscript', $weight = -10) {

    // Note: depending on the theme, this may not place the snippet immediately
    // after the body tag but should be close and it can be altered.
    // @see https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!theme.api.php/group/theme_render/8.2.x
    // The markup is passed through \Drupal\Component\Utility\Xss::filterAdmin()
    // which strips known vectors while allowing a permissive list of HTML tags
    // that are not XSS vectors. (e.g., <script> and <style> are not allowed.)
    // As markup, core removes the 'style' attribute from the noscript snippet.
    // With the inline template type, core does not alter the noscript snippet.
    $contents = $this
      ->getSnippetContents($type);
    $attachment = $contents ? [
      "google_tag_{$type}_tag__{$this->id()}" => [
        '#type' => 'inline_template',
        '#template' => $contents,
        '#weight' => $weight,
      ],
    ] : [];
    return $attachment;
  }

  /**
   * Returns the snippet contents for the snippet type.
   *
   * @param string $type
   *   The snippet type.
   *
   * @return string
   *   The snippet contents.
   */
  public function getSnippetContents($type) {
    $cache = \Drupal::service('cache.data')
      ->get($this
      ->snippetCid($type));
    return $cache ? $cache->data : '';
  }

  /**
   * {@inheritdoc}
   */
  public function getPluginCollections() {
    return [
      'conditions' => $this
        ->getInsertionConditions(),
    ];
  }

  /**
   * Returns an array of configuration arrays keyed by insertion condition.
   *
   * @return array
   *   An array of condition configuration keyed by the condition ID.
   */
  public function getInsertionConfiguration() {
    return $this
      ->getInsertionConditions()
      ->getConfiguration();
  }

  /**
   * Returns an insertion condition for this container.
   *
   * @param string $instance_id
   *   The condition plugin instance ID.
   *
   * @return \Drupal\Core\Condition\ConditionInterface
   *   A condition plugin.
   */
  public function getInsertionCondition($instance_id) {
    return $this
      ->getInsertionConditions()
      ->get($instance_id);
  }

  /**
   * Sets the configuration for an insertion condition.
   *
   * @param string $instance_id
   *   The condition instance ID.
   * @param array $configuration
   *   The condition configuration.
   *
   * @return $this
   *
   * @todo Does this need to set a persistent property?
   */
  public function setInsertionCondition($instance_id, array $configuration) {
    $conditions = $this
      ->getInsertionConditions();
    if (!$conditions
      ->has($instance_id)) {
      $configuration['id'] = $instance_id;
      $conditions
        ->addInstanceId($instance_id, $configuration);
    }
    else {
      $conditions
        ->setInstanceConfiguration($instance_id, $configuration);
    }
    return $this;
  }

  /**
   * Returns the set of insertion conditions for this container.
   *
   * @return \Drupal\Core\Condition\ConditionPluginCollection
   *   A collection of configured condition plugins.
   */
  public function getInsertionConditions() {
    if (!isset($this->conditionCollection)) {
      $this->conditionCollection = new ConditionPluginCollection($this
        ->conditionPluginManager(), $this
        ->get('conditions'));
    }
    return $this->conditionCollection;
  }

  /**
   * Gets the condition plugin manager.
   *
   * @return \Drupal\Core\Executable\ExecutableManagerInterface
   *   The condition plugin manager.
   */
  protected function conditionPluginManager() {
    if (!isset($this->conditionPluginManager)) {
      $this->conditionPluginManager = \Drupal::service('plugin.manager.condition');
    }
    return $this->conditionPluginManager;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
ConfigEntityBase::$isUninstalling private property Whether the config is being deleted by the uninstall process.
ConfigEntityBase::$langcode protected property The language code of the entity's default language.
ConfigEntityBase::$originalId protected property The original ID of the configuration entity.
ConfigEntityBase::$status protected property The enabled/disabled status of the configuration entity. 4
ConfigEntityBase::$third_party_settings protected property Third party entity settings.
ConfigEntityBase::$trustedData protected property Trust supplied data and not use configuration schema on save.
ConfigEntityBase::$uuid protected property The UUID for this entity.
ConfigEntityBase::$_core protected property Information maintained by Drupal core about configuration.
ConfigEntityBase::addDependency protected function Overrides \Drupal\Core\Entity\DependencyTrait:addDependency().
ConfigEntityBase::calculateDependencies public function Calculates dependencies and stores them in the dependency property. Overrides ConfigEntityInterface::calculateDependencies 13
ConfigEntityBase::createDuplicate public function Creates a duplicate of the entity. Overrides EntityBase::createDuplicate 1
ConfigEntityBase::disable public function Disables the configuration entity. Overrides ConfigEntityInterface::disable 1
ConfigEntityBase::enable public function Enables the configuration entity. Overrides ConfigEntityInterface::enable
ConfigEntityBase::get public function Returns the value of a property. Overrides ConfigEntityInterface::get
ConfigEntityBase::getCacheTagsToInvalidate public function Returns the cache tags that should be used to invalidate caches. Overrides EntityBase::getCacheTagsToInvalidate 1
ConfigEntityBase::getConfigDependencyName public function Gets the configuration dependency name. Overrides EntityBase::getConfigDependencyName
ConfigEntityBase::getConfigManager protected static function Gets the configuration manager.
ConfigEntityBase::getConfigTarget public function Gets the configuration target identifier for the entity. Overrides EntityBase::getConfigTarget
ConfigEntityBase::getDependencies public function Gets the configuration dependencies. Overrides ConfigEntityInterface::getDependencies
ConfigEntityBase::getOriginalId public function Gets the original ID. Overrides EntityBase::getOriginalId
ConfigEntityBase::getThirdPartyProviders public function Gets the list of third parties that store information. Overrides ThirdPartySettingsInterface::getThirdPartyProviders
ConfigEntityBase::getThirdPartySetting public function Gets the value of a third-party setting. Overrides ThirdPartySettingsInterface::getThirdPartySetting
ConfigEntityBase::getThirdPartySettings public function Gets all third-party settings of a given module. Overrides ThirdPartySettingsInterface::getThirdPartySettings
ConfigEntityBase::getTypedConfig protected function Gets the typed config manager.
ConfigEntityBase::hasTrustedData public function Gets whether on not the data is trusted. Overrides ConfigEntityInterface::hasTrustedData
ConfigEntityBase::invalidateTagsOnDelete protected static function Override to never invalidate the individual entities' cache tags; the config system already invalidates them. Overrides EntityBase::invalidateTagsOnDelete
ConfigEntityBase::invalidateTagsOnSave protected function Override to never invalidate the entity's cache tag; the config system already invalidates it. Overrides EntityBase::invalidateTagsOnSave
ConfigEntityBase::isInstallable public function Checks whether this entity is installable. Overrides ConfigEntityInterface::isInstallable 2
ConfigEntityBase::isNew public function Overrides Entity::isNew(). Overrides EntityBase::isNew
ConfigEntityBase::isUninstalling public function Returns whether this entity is being changed during the uninstall process. Overrides ConfigEntityInterface::isUninstalling
ConfigEntityBase::link public function Deprecated way of generating a link to the entity. See toLink(). Overrides EntityBase::link
ConfigEntityBase::onDependencyRemoval public function Informs the entity that entities it depends on will be deleted. Overrides ConfigEntityInterface::onDependencyRemoval 7
ConfigEntityBase::preDelete public static function Acts on entities before they are deleted and before hooks are invoked. Overrides EntityBase::preDelete 8
ConfigEntityBase::preSave public function Acts on an entity before the presave hook is invoked. Overrides EntityBase::preSave 13
ConfigEntityBase::save public function Saves an entity permanently. Overrides EntityBase::save 1
ConfigEntityBase::set public function Sets the value of a property. Overrides ConfigEntityInterface::set
ConfigEntityBase::setOriginalId public function Sets the original ID. Overrides EntityBase::setOriginalId
ConfigEntityBase::setStatus public function Sets the status of the configuration entity. Overrides ConfigEntityInterface::setStatus
ConfigEntityBase::setThirdPartySetting public function Sets the value of a third-party setting. Overrides ThirdPartySettingsInterface::setThirdPartySetting
ConfigEntityBase::setUninstalling public function
ConfigEntityBase::sort public static function Helper callback for uasort() to sort configuration entities by weight and label. 6
ConfigEntityBase::status public function Returns whether the configuration entity is enabled. Overrides ConfigEntityInterface::status 4
ConfigEntityBase::toArray public function Gets an array of all property values. Overrides EntityBase::toArray 2
ConfigEntityBase::toUrl public function Gets the URL object for the entity. Overrides EntityBase::toUrl
ConfigEntityBase::trustData public function Sets that the data should be trusted. Overrides ConfigEntityInterface::trustData
ConfigEntityBase::unsetThirdPartySetting public function Unsets a third-party setting. Overrides ThirdPartySettingsInterface::unsetThirdPartySetting
ConfigEntityBase::url public function Gets the public URL for this entity. Overrides EntityBase::url
ConfigEntityBase::urlInfo public function Gets the URL object for the entity. Overrides EntityBase::urlInfo
ConfigEntityBase::__sleep public function Overrides EntityBase::__sleep 4
Container::$blacklist_classes public property The black-listed classes.
Container::$conditionCollection protected property The insertion condition collection.
Container::$conditionPluginManager protected property The condition plugin manager.
Container::$conditions protected property The insertion conditions.
Container::$container_id public property The Google Tag Manager container id.
Container::$data_layer public property The name of the data layer.
Container::$environment_id public property The environment ID.
Container::$environment_token public property The environment token.
Container::$id protected property The machine name for the configuration entity.
Container::$include_classes public property Whether to add the listed classes to the data layer.
Container::$include_environment public property Whether to include the environment items in the applicable snippets.
Container::$label public property The human-readable name of the configuration entity.
Container::$path_list public property The listed paths.
Container::$path_toggle public property Whether to include or exclude the listed paths.
Container::$role_list public property The listed roles.
Container::$role_toggle public property Whether to include or exclude the listed roles.
Container::$status_list public property The listed statuses.
Container::$status_toggle public property Whether to include or exclude the listed statuses.
Container::$weight public property The weight of the configuration entity.
Container::$whitelist_classes public property The white-listed classes.
Container::compactSnippet protected function Returns the compacted snippet.
Container::conditionPluginManager protected function Gets the condition plugin manager.
Container::dataLayerSnippet protected function Returns JavaScript data layer snippet or adds items to data layer.
Container::displayMessage public function Displays a message.
Container::environmentQuery public function Returns a query string with the environment parameters.
Container::fileTag public function Returns tag array for the snippet type.
Container::getInsertionCondition public function Returns an insertion condition for this container.
Container::getInsertionConditions public function Returns the set of insertion conditions for this container.
Container::getInsertionConfiguration public function Returns an array of configuration arrays keyed by insertion condition.
Container::getPluginCollections public function Gets the plugin collections used by this object. Overrides ObjectWithPluginCollectionInterface::getPluginCollections
Container::getSnippetContents public function Returns the snippet contents for the snippet type.
Container::inlineTag public function Returns tag array for the snippet type.
Container::insertSnippet public function Determines whether to insert the snippet on the response.
Container::noscriptSnippet protected function Returns JavaScript noscript snippet.
Container::noscriptTag public function Returns tag array for the snippet type.
Container::pathCheck protected function Determines whether to insert the snippet based on the path settings.
Container::roleCheck protected function Determines whether to insert the snippet based on the user role settings.
Container::scriptSnippet protected function Returns JavaScript script snippet.
Container::setInsertionCondition public function Sets the configuration for an insertion condition.
Container::snippetCid public function Returns the snippet cache ID for a snippet type.
Container::snippetDirectory public function Returns the snippet directory path.
Container::snippets public function Returns array of JavaScript snippets.
Container::snippetURI public function Returns the snippet URI for a snippet type.
Container::statusCheck protected function Determines whether to insert the snippet based on status code settings.
Container::variableClean public function Returns a cleansed variable.
Container::__construct public function Constructs an Entity object. Overrides ConfigEntityBase::__construct
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function Aliased as: traitSleep 1
DependencySerializationTrait::__wakeup public function 2
DependencyTrait::$dependencies protected property The object's dependencies.
DependencyTrait::addDependencies protected function Adds multiple dependencies.
DependencyTrait::addDependency protected function Adds a dependency. Aliased as: addDependencyTrait
EntityBase::$enforceIsNew protected property Boolean indicating whether the entity should be forced to be new.
EntityBase::$entityTypeId protected property The entity type.
EntityBase::$typedData protected property A typed data object wrapping this entity.
EntityBase::access public function Checks data value access. Overrides AccessibleInterface::access 1
EntityBase::bundle public function Gets the bundle of the entity. Overrides EntityInterface::bundle 1
EntityBase::create public static function Constructs a new entity object, without permanently saving it. Overrides EntityInterface::create
EntityBase::delete public function Deletes an entity permanently. Overrides EntityInterface::delete 2
EntityBase::enforceIsNew public function Enforces an entity to be new. Overrides EntityInterface::enforceIsNew
EntityBase::entityManager Deprecated protected function Gets the entity manager.
EntityBase::entityTypeBundleInfo protected function Gets the entity type bundle info service.
EntityBase::entityTypeManager protected function Gets the entity type manager.
EntityBase::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyTrait::getCacheContexts
EntityBase::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyTrait::getCacheMaxAge
EntityBase::getCacheTags public function The cache tags associated with this object. Overrides CacheableDependencyTrait::getCacheTags
EntityBase::getConfigDependencyKey public function Gets the key that is used to store configuration dependencies. Overrides EntityInterface::getConfigDependencyKey
EntityBase::getEntityType public function Gets the entity type definition. Overrides EntityInterface::getEntityType
EntityBase::getEntityTypeId public function Gets the ID of the type of the entity. Overrides EntityInterface::getEntityTypeId
EntityBase::getListCacheTagsToInvalidate protected function The list cache tags to invalidate for this entity.
EntityBase::getTypedData public function Gets a typed data object for this entity object. Overrides EntityInterface::getTypedData
EntityBase::hasLinkTemplate public function Indicates if a link template exists for a given key. Overrides EntityInterface::hasLinkTemplate
EntityBase::id public function Gets the identifier. Overrides EntityInterface::id 11
EntityBase::label public function Gets the label of the entity. Overrides EntityInterface::label 6
EntityBase::language public function Gets the language of the entity. Overrides EntityInterface::language 1
EntityBase::languageManager protected function Gets the language manager.
EntityBase::linkTemplates protected function Gets an array link templates. 1
EntityBase::load public static function Loads an entity. Overrides EntityInterface::load
EntityBase::loadMultiple public static function Loads one or more entities. Overrides EntityInterface::loadMultiple
EntityBase::postCreate public function Acts on a created entity before hooks are invoked. Overrides EntityInterface::postCreate 4
EntityBase::postDelete public static function Acts on deleted entities before the delete hook is invoked. Overrides EntityInterface::postDelete 16
EntityBase::postLoad public static function Acts on loaded entities. Overrides EntityInterface::postLoad 2
EntityBase::postSave public function Acts on a saved entity before the insert or update hook is invoked. Overrides EntityInterface::postSave 14
EntityBase::preCreate public static function Changes the values of an entity before it is created. Overrides EntityInterface::preCreate 5
EntityBase::referencedEntities public function Gets a list of entities referenced by this entity. Overrides EntityInterface::referencedEntities 1
EntityBase::toLink public function Generates the HTML for a link to this entity. Overrides EntityInterface::toLink
EntityBase::uriRelationships public function Gets a list of URI relationships supported by this entity. Overrides EntityInterface::uriRelationships
EntityBase::urlRouteParameters protected function Gets an array of placeholders for this entity. 2
EntityBase::uuid public function Gets the entity UUID (Universally Unique Identifier). Overrides EntityInterface::uuid 1
EntityBase::uuidGenerator protected function Gets the UUID generator.
PluginDependencyTrait::calculatePluginDependencies protected function Calculates and adds dependencies of a specific plugin instance. 1
PluginDependencyTrait::getPluginDependencies protected function Calculates and returns dependencies of a specific plugin instance.
PluginDependencyTrait::moduleHandler protected function Wraps the module handler. 1
PluginDependencyTrait::themeHandler protected function Wraps the theme handler. 1
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
SynchronizableEntityTrait::$isSyncing protected property Whether this entity is being created, updated or deleted through a synchronization process.
SynchronizableEntityTrait::isSyncing public function
SynchronizableEntityTrait::setSyncing public function