abstract class SdlSchemaExtensionPluginBase in GraphQL 8.4
Base class that can be used for schema extension plugins.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\graphql\Plugin\GraphQL\SchemaExtension\SdlSchemaExtensionPluginBase implements ContainerFactoryPluginInterface, SchemaExtensionPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of SdlSchemaExtensionPluginBase
2 files declare their use of SdlSchemaExtensionPluginBase
- ComposableSchemaExampleExtension.php in examples/
graphql_composable/ src/ Plugin/ GraphQL/ SchemaExtension/ ComposableSchemaExampleExtension.php - ExampleSchemaExtension.php in examples/
graphql_example/ src/ Plugin/ GraphQL/ SchemaExtension/ ExampleSchemaExtension.php
File
- src/
Plugin/ GraphQL/ SchemaExtension/ SdlSchemaExtensionPluginBase.php, line 15
Namespace
Drupal\graphql\Plugin\GraphQL\SchemaExtensionView source
abstract class SdlSchemaExtensionPluginBase extends PluginBase implements SchemaExtensionPluginInterface, ContainerFactoryPluginInterface {
/**
* The module handler service.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* {@inheritdoc}
*
* @codeCoverageIgnore
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('module_handler'));
}
/**
* SdlSchemaExtensionPluginBase constructor.
*
* @param array $configuration
* The plugin configuration array.
* @param string $pluginId
* The plugin id.
* @param array $pluginDefinition
* The plugin definition array.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler
* The module handler service.
*
* @codeCoverageIgnore
*/
public function __construct(array $configuration, $pluginId, array $pluginDefinition, ModuleHandlerInterface $moduleHandler) {
parent::__construct($configuration, $pluginId, $pluginDefinition);
$this->moduleHandler = $moduleHandler;
}
/**
* {@inheritdoc}
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
*/
public function getBaseDefinition() {
return $this
->loadDefinitionFile('base');
}
/**
* {@inheritdoc}
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
*/
public function getExtensionDefinition() {
return $this
->loadDefinitionFile('extension');
}
/**
* Loads a schema definition file.
*
* @param string $type
* The type of the definition file to load.
*
* @return string|null
* The loaded definition file content or NULL if it was empty.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
*/
protected function loadDefinitionFile($type) {
$id = $this
->getPluginId();
$definition = $this
->getPluginDefinition();
$module = $this->moduleHandler
->getModule($definition['provider']);
$path = 'graphql/' . $id . '.' . $type . '.graphqls';
$file = $module
->getPath() . '/' . $path;
if (!file_exists($file)) {
throw new InvalidPluginDefinitionException($id, sprintf('The module "%s" needs to have a schema definition "%s" in its folder for "%s" to be valid.', $module
->getName(), $path, $definition['class']));
}
return file_get_contents($file) ?: NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
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. | |
SchemaExtensionPluginInterface:: |
public | function | Registers type and field resolvers in the shared registry. | 2 |
SdlSchemaExtensionPluginBase:: |
protected | property | The module handler service. | |
SdlSchemaExtensionPluginBase:: |
public static | function |
@codeCoverageIgnore Overrides ContainerFactoryPluginInterface:: |
|
SdlSchemaExtensionPluginBase:: |
public | function |
Overrides SchemaExtensionPluginInterface:: |
|
SdlSchemaExtensionPluginBase:: |
public | function |
Overrides SchemaExtensionPluginInterface:: |
|
SdlSchemaExtensionPluginBase:: |
protected | function | Loads a schema definition file. | |
SdlSchemaExtensionPluginBase:: |
public | function |
SdlSchemaExtensionPluginBase constructor. Overrides PluginBase:: |
|
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. |