You are here

class EntityGet in Services 8.4

Same name in this branch
  1. 8.4 src/Plugin/Deriver/EntityGet.php \Drupal\services\Plugin\Deriver\EntityGet
  2. 8.4 src/Plugin/ServiceDefinition/EntityGet.php \Drupal\services\Plugin\ServiceDefinition\EntityGet
Same name and namespace in other branches
  1. 9.0.x src/Plugin/Deriver/EntityGet.php \Drupal\services\Plugin\Deriver\EntityGet

Class \Drupal\services\Plugin\Deriver\EntityGet.

Hierarchy

Expanded class hierarchy of EntityGet

File

src/Plugin/Deriver/EntityGet.php, line 11

Namespace

Drupal\services\Plugin\Deriver
View source
class EntityGet extends EntityDeriverBase {

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    foreach ($this->entityTypeManager
      ->getDefinitions() as $entity_type_id => $entity_type) {
      $this->derivatives[$entity_type_id] = $base_plugin_definition;
      $this->derivatives[$entity_type_id]['title'] = $this
        ->t('@label: Retrieve', [
        '@label' => $entity_type
          ->getLabel(),
      ]);
      $this->derivatives[$entity_type_id]['description'] = $this
        ->t('Retrieves a @entity_type_id object and serializes it as a response to the current request.', [
        '@entity_type_id' => $entity_type_id,
      ]);
      $this->derivatives[$entity_type_id]['category'] = $this
        ->t('@label', [
        '@label' => $entity_type
          ->getLabel(),
      ]);
      $this->derivatives[$entity_type_id]['path'] = "{$entity_type_id}/{{$entity_type_id}}";
      $this->derivatives[$entity_type_id]['context'] = [
        "{$entity_type_id}" => new EntityContextDefinition("entity:{$entity_type_id}", $this
          ->t('@label', [
          '@label' => $entity_type
            ->getLabel(),
        ])),
      ];
    }
    return $this->derivatives;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
EntityDeriverBase::$entityFieldManager protected property The entity field manager.
EntityDeriverBase::$entityTypeManager protected property The entity type manager.
EntityDeriverBase::$entityTypeRepository protected property The entity type repository.
EntityDeriverBase::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
EntityDeriverBase::__construct public function Constructs new EntityViewDeriver.
EntityGet::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
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.