public function EntityRenderedDeriver::getDerivativeDefinitions in GraphQL 8.3
Gets the definition of all derivatives of a base plugin.
Parameters
array $base_plugin_definition: The definition array of the base plugin.
Return value
array An array of full derivative definitions keyed on derivative id.
Overrides DeriverBase::getDerivativeDefinitions
See also
getDerivativeDefinition()
File
- modules/
graphql_core/ src/ Plugin/ Deriver/ Fields/ EntityRenderedDeriver.php, line 57
Class
Namespace
Drupal\graphql_core\Plugin\Deriver\FieldsCode
public function getDerivativeDefinitions($basePluginDefinition) {
foreach ($this->entityTypeManager
->getDefinitions() as $id => $type) {
if ($type instanceof ContentEntityTypeInterface && !empty($this->entityDisplayRepository
->getViewModes($id))) {
$derivative = [
'parents' => [
StringHelper::camelCase($id),
],
'description' => $this
->t("Renders '@type' entities in the given view mode.", [
'@type' => $type
->getLabel(),
]),
'entity_type' => $id,
] + $basePluginDefinition;
if (!isset($derivative['arguments']['mode'])) {
$derivative['arguments'] = isset($derivative['arguments']) ? $derivative['arguments'] : [];
$derivative['arguments']['mode'] = [
'type' => StringHelper::camelCase($id, 'display', 'mode', 'id'),
'optional' => TRUE,
];
}
$this->derivatives["entity:{$id}"] = $derivative;
}
}
return parent::getDerivativeDefinitions($basePluginDefinition);
}