You are here

class EqViewsData in EntityFieldQuery Views Backend 8

Hierarchy

Expanded class hierarchy of EqViewsData

1 file declares its use of EqViewsData
EntityTypeAlter.php in src/Hooks/EntityTypeAlter.php
Contains \Drupal\efq_views\Hooks\EntityTypeAlter.

File

src/EqViewsData.php, line 16
Contains \Drupal\efq_views\EqViewsData.

Namespace

Drupal\efq_views
View source
class EqViewsData implements EntityViewsDataInterface, EntityHandlerInterface {
  use StringTranslationTrait;

  /**
   * @var \Drupal\Core\Entity\EntityTypeInterface
   */
  protected $entityType;
  public function __construct(EntityTypeInterface $entityType) {
    $this->entityType = $entityType;
  }

  /**
   * {@inheritdoc}
   */
  public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
    return new static($entity_type);
  }

  /**
   * {@inheritdoc}
   */
  public function getViewsData() {
    $data = [];
    $base_table = 'eq__' . $this->entityType
      ->id();
    $data[$base_table]['table']['group'] = $this
      ->t('EQ @label', [
      '@label' => $this->entityType
        ->getLabel(),
    ]);
    $data[$base_table]['table']['provider'] = $this->entityType
      ->getProvider();
    $data[$base_table]['table']['base'] = [
      'query_id' => 'entity_field_query',
      'field' => $this->entityType
        ->getKey('id'),
      'title' => $this
        ->t('EQ @label', [
        '@label' => $this->entityType
          ->getLabel(),
      ]),
      'cache_contexts' => $this->entityType
        ->getListCacheContexts(),
    ];
    return $data;
  }

  /**
   * {@inheritdoc}
   */
  public function getViewsTableForEntityType(EntityTypeInterface $entity_type) {
    return 'efq__' . $entity_type
      ->id();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EqViewsData::$entityType protected property
EqViewsData::createInstance public static function Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface::createInstance
EqViewsData::getViewsData public function Returns views data for the entity type. Overrides EntityViewsDataInterface::getViewsData
EqViewsData::getViewsTableForEntityType public function Gets the table of an entity type to be used as base table in views. Overrides EntityViewsDataInterface::getViewsTableForEntityType
EqViewsData::__construct 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.