abstract class InterfacePluginBase in GraphQL 8.3
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\graphql\Plugin\GraphQL\Interfaces\InterfacePluginBase implements TypePluginInterface uses CacheablePluginTrait, DescribablePluginTrait
Expanded class hierarchy of InterfacePluginBase
10 files declare their use of InterfacePluginBase
- Entity.php in modules/
graphql_core/ src/ Plugin/ GraphQL/ Interfaces/ Entity/ Entity.php - EntityDescribable.php in modules/
graphql_core/ src/ Plugin/ GraphQL/ Interfaces/ Entity/ EntityDescribable.php - EntityOwnable.php in modules/
graphql_core/ src/ Plugin/ GraphQL/ Interfaces/ Entity/ EntityOwnable.php - EntityPublishable.php in modules/
graphql_core/ src/ Plugin/ GraphQL/ Interfaces/ Entity/ EntityPublishable.php - EntityRevisionable.php in modules/
graphql_core/ src/ Plugin/ GraphQL/ Interfaces/ Entity/ EntityRevisionable.php
1 string reference to 'InterfacePluginBase'
File
- src/
Plugin/ GraphQL/ Interfaces/ InterfacePluginBase.php, line 14
Namespace
Drupal\graphql\Plugin\GraphQL\InterfacesView source
abstract class InterfacePluginBase extends PluginBase implements TypePluginInterface {
use CacheablePluginTrait;
use DescribablePluginTrait;
/**
* {@inheritdoc}
*/
public static function createInstance(SchemaBuilderInterface $builder, TypePluginManager $manager, $definition, $id) {
return new InterfaceType([
'name' => $definition['name'],
'description' => $definition['description'],
'contexts' => function () use ($builder, $definition) {
$types = $builder
->getSubTypes($definition['name']);
return array_reduce($types, function ($carry, $current) use ($builder) {
$type = $builder
->getType($current);
if (!empty($type->config['contexts'])) {
$contexts = $type->config['contexts'];
$contexts = is_callable($contexts) ? $contexts() : $contexts;
return Cache::mergeContexts($carry, $contexts);
}
return $carry;
}, $definition['contexts']);
},
'fields' => function () use ($builder, $definition) {
$fields = $builder
->getFields($definition['name']);
if (!empty($definition['interfaces'])) {
$inherited = array_map(function ($name) use ($builder) {
return $builder
->getFields($name);
}, $definition['interfaces']);
$inherited = call_user_func_array('array_merge', $inherited);
return array_merge($inherited, $fields);
}
return $fields;
},
'resolveType' => function ($value, $context, $info) use ($builder, $definition) {
return $builder
->resolveType($definition['name'], $value, $context, $info);
},
]);
}
/**
* {@inheritdoc}
*/
public function getDefinition() {
$definition = $this
->getPluginDefinition();
return [
'name' => $definition['name'],
'description' => $this
->buildDescription($definition),
'interfaces' => $this
->buildInterfaces($definition),
'contexts' => $this
->buildCacheContexts($definition),
];
}
/**
* Builds the list of interfaces inherited by this interface.
*
* @param array $definition
* The plugin definition array.
*
* @return array
* The list of interfaces that this interface inherits from.
*/
protected function buildInterfaces($definition) {
return $definition['interfaces'] ?: [];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheablePluginTrait:: |
protected | function | ||
DescribablePluginTrait:: |
protected | function | ||
InterfacePluginBase:: |
protected | function | Builds the list of interfaces inherited by this interface. | |
InterfacePluginBase:: |
public static | function |
Overrides TypePluginInterface:: |
|
InterfacePluginBase:: |
public | function |
Returns the plugin's type or field definition for the schema. Overrides TypePluginInterface:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |