You are here

public function EntityFieldDeriverBase::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/EntityFieldDeriverBase.php, line 102

Class

EntityFieldDeriverBase
Generate GraphQLField plugins for config fields.

Namespace

Drupal\graphql_core\Plugin\Deriver

Code

public function getDerivativeDefinitions($basePluginDefinition) {
  foreach ($this->entityTypeManager
    ->getDefinitions() as $entityTypeId => $entityType) {
    if (!$entityType
      ->entityClassImplements(FieldableEntityInterface::class)) {
      continue;
    }
    foreach ($this->entityFieldManager
      ->getBaseFieldDefinitions($entityTypeId) as $fieldDefinition) {
      if ($derivatives = $this
        ->getDerivativeDefinitionsFromFieldDefinition($fieldDefinition, $basePluginDefinition)) {
        $this->derivatives = array_merge($this->derivatives, $derivatives);
      }
    }
    foreach ($this->entityBundleInfo
      ->getBundleInfo($entityTypeId) as $bundleId => $bundleInfo) {
      foreach ($this->entityFieldManager
        ->getFieldDefinitions($entityTypeId, $bundleId) as $fieldDefinition) {
        if ($derivatives = $this
          ->getDerivativeDefinitionsFromFieldDefinition($fieldDefinition, $basePluginDefinition)) {
          $this->derivatives = array_merge($this->derivatives, $derivatives);
        }
      }
    }
  }
  return $this->derivatives;
}