You are here

protected function SimpleFacebookPixelSettingsForm::getViewContentEntities in Simple Facebook Pixel 8

Gets content entities for which it is possible to enable ViewContent event.

Return value

array The list of entities.

1 call to SimpleFacebookPixelSettingsForm::getViewContentEntities()
SimpleFacebookPixelSettingsForm::buildForm in src/Form/SimpleFacebookPixelSettingsForm.php
Form constructor.

File

src/Form/SimpleFacebookPixelSettingsForm.php, line 351

Class

SimpleFacebookPixelSettingsForm
Class SimpleFacebookPixelSettingsForm.

Namespace

Drupal\simple_facebook_pixel\Form

Code

protected function getViewContentEntities() {
  $result = [];
  if ($this->entityTypeManager
    ->hasDefinition('node_type')) {
    $content_types = $this->entityTypeManager
      ->getStorage('node_type')
      ->loadMultiple();
    foreach ($content_types as $content_type) {
      $result['node:' . $content_type
        ->getOriginalId()] = $this
        ->t('Node: @label', [
        '@label' => $content_type
          ->label(),
      ]);
    }
  }
  if ($this->entityTypeManager
    ->hasDefinition('taxonomy_vocabulary')) {
    $vocabularies = $this->entityTypeManager
      ->getStorage('taxonomy_vocabulary')
      ->loadMultiple();
    foreach ($vocabularies as $vocabulary) {
      $result['taxonomy_term:' . $vocabulary
        ->getOriginalId()] = $this
        ->t('Taxonomy: @label', [
        '@label' => $vocabulary
          ->label(),
      ]);
    }
  }
  if ($this->entityTypeManager
    ->hasDefinition('commerce_product')) {
    $commerce_products = $this->entityTypeManager
      ->getStorage('commerce_product_type')
      ->loadMultiple();
    foreach ($commerce_products as $commerce_product) {
      $result['commerce_product:' . $commerce_product
        ->getOriginalId()] = $this
        ->t('Commerce Product: @label', [
        '@label' => $commerce_product
          ->label(),
      ]);
    }
  }
  return $result;
}