You are here

class Numbers in GraphQL 8.3

Same name in this branch
  1. 8.3 tests/modules/graphql_enum_test/src/Plugin/GraphQL/Enums/Numbers.php \Drupal\graphql_enum_test\Plugin\GraphQL\Enums\Numbers
  2. 8.3 tests/modules/graphql_enum_test/src/Plugin/GraphQL/Fields/Numbers.php \Drupal\graphql_enum_test\Plugin\GraphQL\Fields\Numbers

Generates an enumeration of numbers.

Plugin annotation


@GraphQLEnum(
  id = "numbers",
  name = "Numbers"
)

Hierarchy

Expanded class hierarchy of Numbers

File

tests/modules/graphql_enum_test/src/Plugin/GraphQL/Enums/Numbers.php, line 16

Namespace

Drupal\graphql_enum_test\Plugin\GraphQL\Enums
View source
class Numbers extends EnumPluginBase {

  /**
   * A constant list of numbers.
   *
   * @var string[]
   */
  public static $NUMBERS = [
    'zero',
    'one',
    'two',
    'three',
    'four',
    'five',
    'six',
    'seven',
    'eight',
    'nine',
  ];

  /**
   * {@inheritdoc}
   */
  public function buildEnumValues($definition) {
    $values = [];
    foreach (static::$NUMBERS as $num => $word) {
      $values[strtoupper($word)] = [
        'value' => $num,
        'description' => ucfirst($word),
      ];
    }
    return $values;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheablePluginTrait::buildCacheContexts protected function
DescribablePluginTrait::buildDescription protected function
EnumPluginBase::buildEnumDescription protected function Builds the description of an enum item.
EnumPluginBase::buildEnumValue protected function Builds the value of an enum item.
EnumPluginBase::createInstance public static function Overrides TypePluginInterface::createInstance
EnumPluginBase::getDefinition public function Returns the plugin's type or field definition for the schema. Overrides TypePluginInterface::getDefinition
Numbers::$NUMBERS public static property A constant list of numbers.
Numbers::buildEnumValues public function Builds the enum values. Overrides EnumPluginBase::buildEnumValues
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. 92