abstract class TypePluginBase in GraphQL 8.3
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\graphql\Plugin\GraphQL\Types\TypePluginBase implements TypePluginInterface uses CacheablePluginTrait, DescribablePluginTrait
Expanded class hierarchy of TypePluginBase
22 files declare their use of TypePluginBase
- Bike.php in tests/
modules/ graphql_plugin_test/ src/ Plugin/ GraphQL/ Types/ Bike.php - Car.php in tests/
modules/ graphql_plugin_test/ src/ Plugin/ GraphQL/ Types/ Car.php - ConstraintViolation.php in modules/
graphql_core/ src/ Plugin/ GraphQL/ Types/ Mutations/ ConstraintViolation.php - DefaultInternalUrl.php in modules/
graphql_core/ src/ Plugin/ GraphQL/ Types/ Routing/ DefaultInternalUrl.php - EntityBundle.php in modules/
graphql_core/ src/ Plugin/ GraphQL/ Types/ Entity/ EntityBundle.php
1 string reference to 'TypePluginBase'
File
- src/
Plugin/ GraphQL/ Types/ TypePluginBase.php, line 16
Namespace
Drupal\graphql\Plugin\GraphQL\TypesView source
abstract class TypePluginBase extends PluginBase implements TypePluginInterface {
use CacheablePluginTrait;
use DescribablePluginTrait;
/**
* {@inheritdoc}
*/
public static function createInstance(SchemaBuilderInterface $builder, TypePluginManager $manager, $definition, $id) {
return new ObjectType([
'name' => $definition['name'],
'description' => $definition['description'],
'contexts' => $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;
},
'interfaces' => function () use ($builder, $definition) {
return array_filter(array_map(function ($name) use ($builder) {
return $builder
->getType($name);
}, $definition['interfaces']), function ($type) {
return $type instanceof InterfaceType;
});
},
'isTypeOf' => function ($object, $context, ResolveInfo $info) use ($manager, $id) {
$instance = $manager
->getInstance([
'id' => $id,
]);
return $instance
->applies($object, $context, $info);
},
]);
}
/**
* {@inheritdoc}
*/
public function getDefinition() {
$definition = $this
->getPluginDefinition();
return [
'name' => $definition['name'],
'description' => $this
->buildDescription($definition),
'interfaces' => $this
->buildInterfaces($definition),
'unions' => $this
->buildUnions($definition),
'contexts' => $this
->buildCacheContexts($definition),
'weight' => $definition['weight'],
];
}
/**
* Builds the list of interfaces that this type implements.
*
* @param array $definition
* The plugin definition array.
*
* @return array
* The list of interfaces implemented by this type.
*/
protected function buildInterfaces($definition) {
return array_unique($definition['interfaces']);
}
/**
* Builds the list of unions that this type belongs to.
*
* @param array $definition
* The plugin definition array.
*
* @return array
* The list of unions that this type belongs to.
*/
protected function buildUnions($definition) {
return array_unique($definition['unions']);
}
/**
* Checks whether this type applies to a given object.
*
* @param mixed $object
* The object to check against.
* @param \Drupal\graphql\GraphQL\Execution\ResolveContext $context
* The resolve context.
* @param \GraphQL\Type\Definition\ResolveInfo $info
* The resolve info object.
*
* @return null|bool
* TRUE if this type applies to the given object or FALSE if it doesn't.
*/
public function applies($object, ResolveContext $context, ResolveInfo $info) {
return NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheablePluginTrait:: |
protected | function | ||
DescribablePluginTrait:: |
protected | function | ||
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 |
TypePluginBase:: |
public | function | Checks whether this type applies to a given object. | 9 |
TypePluginBase:: |
protected | function | Builds the list of interfaces that this type implements. | |
TypePluginBase:: |
protected | function | Builds the list of unions that this type belongs to. | |
TypePluginBase:: |
public static | function |
Overrides TypePluginInterface:: |
|
TypePluginBase:: |
public | function |
Returns the plugin's type or field definition for the schema. Overrides TypePluginInterface:: |