class EntityTypeDeriver in GraphQL 8.3
Same name in this branch
- 8.3 modules/graphql_core/src/Plugin/Deriver/Interfaces/EntityTypeDeriver.php \Drupal\graphql_core\Plugin\Deriver\Interfaces\EntityTypeDeriver
- 8.3 modules/graphql_core/src/Plugin/Deriver/Types/EntityTypeDeriver.php \Drupal\graphql_core\Plugin\Deriver\Types\EntityTypeDeriver
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\graphql_core\Plugin\Deriver\EntityTypeDeriverBase implements ContainerDeriverInterface
- class \Drupal\graphql_core\Plugin\Deriver\Interfaces\EntityTypeDeriver uses StringTranslationTrait
- class \Drupal\graphql_core\Plugin\Deriver\EntityTypeDeriverBase implements ContainerDeriverInterface
Expanded class hierarchy of EntityTypeDeriver
File
- modules/
graphql_core/ src/ Plugin/ Deriver/ Interfaces/ EntityTypeDeriver.php, line 10
Namespace
Drupal\graphql_core\Plugin\Deriver\InterfacesView source
class EntityTypeDeriver extends EntityTypeDeriverBase {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($basePluginDefinition) {
foreach ($this->entityTypeManager
->getDefinitions() as $typeId => $type) {
if (!$type instanceof ContentEntityTypeInterface) {
continue;
}
$bundles = $this->entityTypeBundleInfo
->getAllBundleInfo();
// Only create a base interface for types that support bundles.
if (!$type
->hasKey('bundle') && array_key_exists($typeId, $bundles) && count($bundles[$typeId])) {
continue;
}
$derivative = [
'name' => StringHelper::camelCase($typeId),
'description' => $this
->t("The '@type' entity type.", [
'@type' => $type
->getLabel(),
]),
'type' => "entity:{$typeId}",
'interfaces' => $this
->getInterfaces($type, $basePluginDefinition),
'entity_type' => $typeId,
] + $basePluginDefinition;
if ($typeId === 'node') {
// TODO: Make this more generic somehow.
$derivative['response_cache_contexts'][] = 'user.node_grants:view';
}
$this->derivatives[$typeId] = $derivative;
}
return parent::getDerivativeDefinitions($basePluginDefinition);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
EntityTypeDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
EntityTypeDeriverBase:: |
protected | property | Bundle info manager. | |
EntityTypeDeriverBase:: |
protected | property | The entity type manager. | |
EntityTypeDeriverBase:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
EntityTypeDeriverBase:: |
protected | function | Retrieve the interfaces that the entity type should implement. | |
EntityTypeDeriverBase:: |
public | function | EntityTypeDeriver constructor. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |