class RestResource

Same name in this branch
  1. 11.x core/modules/rest/src/Annotation/RestResource.php \Drupal\rest\Annotation\RestResource
Same name and namespace in other branches
  1. 9 core/modules/rest/src/Annotation/RestResource.php \Drupal\rest\Annotation\RestResource
  2. 8.9.x core/modules/rest/src/Annotation/RestResource.php \Drupal\rest\Annotation\RestResource
  3. 10 core/modules/rest/src/Attribute/RestResource.php \Drupal\rest\Attribute\RestResource
  4. 10 core/modules/rest/src/Annotation/RestResource.php \Drupal\rest\Annotation\RestResource

Defines a REST resource attribute object.

Plugin Namespace: Plugin\rest\resource

For a working example, see \Drupal\dblog\Plugin\rest\resource\DbLogResource

Attributes

#[\Attribute(\Attribute::TARGET_CLASS)]

Hierarchy

Expanded class hierarchy of RestResource

See also

\Drupal\rest\Plugin\Type\ResourcePluginManager

\Drupal\rest\Plugin\ResourceBase

\Drupal\rest\Plugin\ResourceInterface

Plugin API

Related topics

6 files declare their use of RestResource
DbLogResource.php in core/modules/dblog/src/Plugin/rest/resource/DbLogResource.php
EntityResource.php in core/modules/rest/src/Plugin/rest/resource/EntityResource.php
FileUploadResource.php in core/modules/file/src/Plugin/rest/resource/FileUploadResource.php
NoSerializationClassTestResource.php in core/modules/rest/tests/modules/rest_test/src/Plugin/rest/resource/NoSerializationClassTestResource.php
ResourcePluginManager.php in core/modules/rest/src/Plugin/Type/ResourcePluginManager.php

... See full list

File

core/modules/rest/src/Attribute/RestResource.php, line 24

Namespace

Drupal\rest\Attribute
View source
class RestResource extends Plugin {
  
  /**
   * Constructs a RestResource attribute.
   *
   * @param string $id
   *   The REST resource plugin ID.
   * @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
   *   The human-readable name of the REST resource plugin.
   * @param string|null $serialization_class
   *   (optional) The serialization class to deserialize serialized data into.
   * @param class-string|null $deriver
   *   (optional) The deriver class for the rest resource.
   * @param array $uri_paths
   *   (optional) The URI paths that this REST resource plugin provides.
   *   - key: The link relation type plugin ID.
   *   - value: The URL template.
   *
   * @see \Symfony\Component\Serializer\SerializerInterface
   * @see core/core.link_relation_types.yml
   */
  public function __construct(public readonly string $id, public readonly TranslatableMarkup $label, public readonly ?string $serialization_class = NULL, public readonly ?string $deriver = NULL, public readonly array $uri_paths = []) {
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
AttributeBase::$class protected property The class used for this attribute class.
AttributeBase::$provider protected property The provider of the attribute class.
AttributeBase::get public function Gets the value of an attribute. Overrides AttributeInterface::get 7
AttributeBase::getClass public function Gets the class of the attribute class. Overrides AttributeInterface::getClass 1
AttributeBase::getId public function Gets the unique ID for this attribute class. Overrides AttributeInterface::getId
AttributeBase::getProvider public function Gets the name of the provider of the attribute class. Overrides AttributeInterface::getProvider
AttributeBase::setClass public function Sets the class of the attributed class. Overrides AttributeInterface::setClass 1
AttributeBase::setProvider public function Sets the name of the provider of the attribute class. Overrides AttributeInterface::setProvider 1
RestResource::__construct public function Constructs a RestResource attribute. Overrides Plugin::__construct

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.