You are here

class JsonRpcParameterDefinition in JSON-RPC 8

Same name and namespace in other branches
  1. 2.x src/Annotation/JsonRpcParameterDefinition.php \Drupal\jsonrpc\Annotation\JsonRpcParameterDefinition

Defines a JsonRpcParameterDefinition annotation object.

Hierarchy

Expanded class hierarchy of JsonRpcParameterDefinition

See also

\Drupal\jsonrpc\Plugin\JsonRpcServiceManager

Plugin API

1 file declares its use of JsonRpcParameterDefinition
AnnotationNormalizer.php in modules/jsonrpc_discovery/src/Normalizer/AnnotationNormalizer.php
1 string reference to 'JsonRpcParameterDefinition'
AnnotationNormalizer::getAnnotationType in modules/jsonrpc_discovery/src/Normalizer/AnnotationNormalizer.php
Extract the annotation type.

File

src/Annotation/JsonRpcParameterDefinition.php, line 15

Namespace

Drupal\jsonrpc\Annotation
View source
class JsonRpcParameterDefinition implements ParameterDefinitionInterface {

  /**
   * The name of the parameter if the params are by-name, an offset otherwise.
   *
   * @var string|int
   */
  protected $id;

  /**
   * The parameter schema.
   *
   * @var array
   */
  public $schema = NULL;

  /**
   * A description of the parameter.
   *
   * @var \Drupal\Core\Annotation\Translation
   *
   * @ingroup plugin_translatable
   */
  public $description;

  /**
   * The parameter factory.
   *
   * @var string
   */
  public $factory;

  /**
   * Whether the parameter is required.
   *
   * @var bool
   */
  public $required;

  /**
   * {@inheritdoc}
   */
  public function getFactory() {
    return $this->factory;
  }

  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    return $this->description;
  }

  /**
   * {@inheritdoc}
   */
  public function isRequired() {
    return isset($this->required) ? $this->required : FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function getSchema() {
    if (!isset($this->schema) && isset($this->factory)) {
      $this->schema = call_user_func_array([
        $this->factory,
        'schema',
      ], [
        $this,
      ]);
    }
    return $this->schema;
  }

  /**
   * {@inheritdoc}
   */
  public function get() {
    return $this;
  }

  /**
   * Sets the parameter ID.
   *
   * @param string|int $id
   *   The ID to set.
   */
  public function setId($id) {
    $this->id = $id;
  }

  /**
   * {@inheritdoc}
   */
  public function getId() {
    return $this->id;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
JsonRpcParameterDefinition::$description public property A description of the parameter.
JsonRpcParameterDefinition::$factory public property The parameter factory.
JsonRpcParameterDefinition::$id protected property The name of the parameter if the params are by-name, an offset otherwise.
JsonRpcParameterDefinition::$required public property Whether the parameter is required.
JsonRpcParameterDefinition::$schema public property The parameter schema.
JsonRpcParameterDefinition::get public function
JsonRpcParameterDefinition::getDescription public function The description of the parameter for the method. Overrides ParameterDefinitionInterface::getDescription
JsonRpcParameterDefinition::getFactory public function Get the parameter factory class. Overrides ParameterDefinitionInterface::getFactory
JsonRpcParameterDefinition::getId public function The name of the parameter if the params are by-name, an offset otherwise. Overrides ParameterDefinitionInterface::getId
JsonRpcParameterDefinition::getSchema public function Gets the parameter schema. Overrides ParameterDefinitionInterface::getSchema
JsonRpcParameterDefinition::isRequired public function Whether the parameter is required. Overrides ParameterDefinitionInterface::isRequired
JsonRpcParameterDefinition::setId public function Sets the parameter ID.