class DataProviderResource in RESTful 7.2
This data provider creates a resource and uses it to access the data.
Class DataProviderResource @package Drupal\restful\Plugin\resource\DataProvider
Hierarchy
- class \Drupal\restful\Plugin\resource\DataProvider\DataProvider implements DataProviderInterface
- class \Drupal\restful\Plugin\resource\DataProvider\DataProviderResource implements DataProviderResourceInterface
Expanded class hierarchy of DataProviderResource
1 file declares its use of DataProviderResource
- ResourceFieldEntityReference.php in src/
Plugin/ resource/ Field/ ResourceFieldEntityReference.php - Contains \Drupal\restful\Plugin\resource\Field\ResourceFieldEntityReference.
File
- src/
Plugin/ resource/ DataProvider/ DataProviderResource.php, line 23 - Contains \Drupal\restful\Plugin\resource\DataProvider\DataProviderResource.
Namespace
Drupal\restful\Plugin\resource\DataProviderView source
class DataProviderResource extends DataProvider implements DataProviderResourceInterface {
/**
* The referenced resource.
*
* @var ResourceInterface
*/
protected $resource;
/**
* The referenced data provider.
*
* @var DataProviderInterface
*/
protected $referencedDataProvider;
/**
* Constructor.
*
* @param RequestInterface $request
* The request.
* @param ResourceFieldCollectionInterface $field_definitions
* The field definitions.
* @param object $account
* The authenticated account.
* @param string $plugin_id
* The resource ID.
* @param string $resource_path
* The resource path.
* @param array $options
* The plugin options for the data provider.
* @param string $langcode
* (Optional) The entity language code.
* @param ResourceInterface $resource
* The referenced resource.
*/
public function __construct(RequestInterface $request, ResourceFieldCollectionInterface $field_definitions, $account, $plugin_id, $resource_path, array $options, $langcode = NULL, ResourceInterface $resource = NULL) {
$resource
->setRequest($request);
$this->resource = $resource;
$this->referencedDataProvider = $resource
->getDataProvider();
parent::__construct($request, $field_definitions, $account, $plugin_id, $resource_path, $options, $langcode);
}
/**
* {@inheritdoc}
*/
public static function init(RequestInterface $request, $resource_name, array $version, $resource_path = NULL) {
/* @var ResourceInterface $resource */
$instance_id = $resource_name . PluginBase::DERIVATIVE_SEPARATOR . $version[0] . '.' . $version[1];
$resource = restful()
->getResourceManager()
->getPluginCopy($instance_id, Request::create('', array(), RequestInterface::METHOD_GET));
$plugin_definition = $resource
->getPluginDefinition();
$resource
->setPath($resource_path);
return new static($request, $resource
->getFieldDefinitions(), $resource
->getAccount(), $resource
->getPluginId(), $resource
->getPath(), $plugin_definition['dataProvider'], static::getLanguage(), $resource);
}
/**
* {@inheritdoc}
*/
public function index() {
return $this->referencedDataProvider
->index();
}
/**
* {@inheritdoc}
*/
public function getIndexIds() {
return $this->referencedDataProvider
->getIndexIds();
}
/**
* {@inheritdoc}
*/
public function create($object) {
return $this->referencedDataProvider
->create($object);
}
/**
* {@inheritdoc}
*/
public function view($identifier) {
return $this->referencedDataProvider
->view($identifier);
}
/**
* {@inheritdoc}
*/
public function viewMultiple(array $identifiers) {
return $this->referencedDataProvider
->viewMultiple($identifiers);
}
/**
* {@inheritdoc}
*/
public function update($identifier, $object, $replace = FALSE) {
return $this->referencedDataProvider
->update($identifier, $object, $replace);
}
/**
* {@inheritdoc}
*/
public function remove($identifier) {
$this->referencedDataProvider
->remove($identifier);
}
/**
* {@inheritdoc}
*/
public function merge($identifier, $object) {
if (!$identifier) {
return $this->referencedDataProvider
->create($object);
}
$replace = ($method = $this
->getRequest()
->getMethod()) ? $method == RequestInterface::METHOD_PUT : FALSE;
return $this->referencedDataProvider
->update($identifier, $object, $replace);
}
/**
* {@inheritdoc}
*/
public function count() {
return $this->referencedDataProvider
->count();
}
/**
* {@inheritdoc}
*/
protected function initDataInterpreter($identifier) {
return NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DataProvider:: |
protected | property | The account authenticated from the request for entity access checks. | |
DataProvider:: |
protected | property | The field definitions. | |
DataProvider:: |
protected | property | Determines the language of the items that should be returned. | |
DataProvider:: |
protected | property | Array of metadata. Use this as a mean to pass info to the render layer. | |
DataProvider:: |
protected | property | User defined options. | |
DataProvider:: |
protected | property | Resource identifier. | |
DataProvider:: |
protected | property | Determines the number of items that should be returned when viewing lists. | |
DataProvider:: |
protected | property | The request | |
DataProvider:: |
protected | property | The resource path. | |
DataProvider:: |
protected | function | Adds query tags and metadata to the EntityFieldQuery. | 2 |
DataProvider:: |
public | function |
Adds the options in the provided array to the data provider options. Overrides DataProviderInterface:: |
|
DataProvider:: |
public | function |
Generates the canonical path for a given path. Overrides DataProviderInterface:: |
1 |
DataProvider:: |
public | function |
Return the discovery information for the given entity. Overrides DataProviderInterface:: |
|
DataProvider:: |
public | function |
Gets the authenticated account. Overrides DataProviderInterface:: |
|
DataProvider:: |
public | function |
Gets the entity context. Overrides DataProviderInterface:: |
3 |
DataProvider:: |
public | function |
Get the language code. Overrides DataProviderInterface:: |
|
DataProvider:: |
protected static | function | Gets the global language. | |
DataProvider:: |
public | function |
Returns the metadata collection. Overrides DataProviderInterface:: |
|
DataProvider:: |
public | function |
Gets the data provider options. Overrides DataProviderInterface:: |
|
DataProvider:: |
public | function |
Gets the range. Overrides DataProviderInterface:: |
|
DataProvider:: |
public | function |
Gets the request. Overrides DataProviderInterface:: |
|
DataProvider:: |
public | function |
Get the resource path. Overrides DataProviderInterface:: |
|
DataProvider:: |
protected | function | Initialize the empty resource field collection to bundle the output. | |
DataProvider:: |
public static | function |
Checks if the passed in string is a dot-nested field. Overrides DataProviderInterface:: |
|
DataProvider:: |
protected static | function | Check if a conjunction is valid for filtering. | 1 |
DataProvider:: |
protected static | function | Check if an operator is valid for filtering. | 1 |
DataProvider:: |
public | function |
Checks if the provided field can be used with the current method. Overrides DataProviderInterface:: |
|
DataProvider:: |
protected | function | Filter the query for list. | |
DataProvider:: |
protected | function | Parses the request object to get the pagination options. | |
DataProvider:: |
protected | function | Parses the request to get the sorting options. | |
DataProvider:: |
public static | function |
Processes the input for a filter and adds the appropriate defaults. Overrides DataProviderInterface:: |
|
DataProvider:: |
public | function |
Sets the authenticated account. Overrides DataProviderInterface:: |
|
DataProvider:: |
protected | function | Sets an HTTP header. | |
DataProvider:: |
public | function |
Sets the language code. Overrides DataProviderInterface:: |
|
DataProvider:: |
public | function |
Sets the options. Overrides DataProviderInterface:: |
|
DataProvider:: |
public | function |
Sets the range. Overrides DataProviderInterface:: |
|
DataProvider:: |
public | function |
Sets the request. Overrides DataProviderInterface:: |
|
DataProvider:: |
public | function |
Set the resource path. Overrides DataProviderInterface:: |
|
DataProviderResource:: |
protected | property | The referenced data provider. | |
DataProviderResource:: |
protected | property | The referenced resource. | |
DataProviderResource:: |
public | function |
Counts the total results for the index call. Overrides CrudInterface:: |
|
DataProviderResource:: |
public | function |
Create operation. Overrides CrudInterface:: |
|
DataProviderResource:: |
public | function |
Returns the ID to render for the current index GET request. Overrides DataProviderInterface:: |
|
DataProviderResource:: |
public | function |
List operation. Overrides DataProvider:: |
|
DataProviderResource:: |
public static | function |
Creates a new DataProviderResource object from the resource info. Overrides DataProviderResourceInterface:: |
|
DataProviderResource:: |
protected | function |
Get the data interpreter. Overrides DataProvider:: |
|
DataProviderResource:: |
public | function |
Create or update an item based on the payload. Overrides DataProviderResourceInterface:: |
|
DataProviderResource:: |
public | function |
Delete operation. Overrides CrudInterface:: |
|
DataProviderResource:: |
public | function |
Update operation. Overrides CrudInterface:: |
|
DataProviderResource:: |
public | function |
Read operation. Overrides CrudInterface:: |
|
DataProviderResource:: |
public | function |
Read operation. Overrides CrudInterface:: |
|
DataProviderResource:: |
public | function |
Constructor. Overrides DataProvider:: |