public function DataProviderVariable::view in RESTful 7.2
Read operation.
Parameters
mixed $identifier: The ID of thing being viewed.
Return value
array An array of data for the thing being viewed.
Overrides CrudInterface::view
3 calls to DataProviderVariable::view()
- DataProviderVariable::create in modules/
restful_example/ src/ Plugin/ resource/ variables/ DataProviderVariable.php - Create operation.
- DataProviderVariable::update in modules/
restful_example/ src/ Plugin/ resource/ variables/ DataProviderVariable.php - Update operation.
- DataProviderVariable::viewMultiple in modules/
restful_example/ src/ Plugin/ resource/ variables/ DataProviderVariable.php - Read operation.
File
- modules/
restful_example/ src/ Plugin/ resource/ variables/ DataProviderVariable.php, line 69 - Contains \Drupal\restful_example\Plugin\resource\variables\DataProviderVariable.
Class
- DataProviderVariable
- Class DataProviderVariable.
Namespace
Drupal\restful_example\Plugin\resource\variablesCode
public function view($identifier) {
$resource_field_collection = $this
->initResourceFieldCollection($identifier);
$input = $this
->getRequest()
->getParsedInput();
$limit_fields = !empty($input['fields']) ? explode(',', $input['fields']) : array();
foreach ($this->fieldDefinitions as $resource_field_name => $resource_field) {
/* @var \Drupal\restful\Plugin\resource\Field\ResourceFieldInterface $resource_field */
if ($limit_fields && !in_array($resource_field_name, $limit_fields)) {
// Limit fields doesn't include this property.
continue;
}
if (!$this
->methodAccess($resource_field) || !$resource_field
->access('view', $resource_field_collection
->getInterpreter())) {
// The field does not apply to the current method or has denied
// access.
continue;
}
$resource_field_collection
->set($resource_field
->id(), $resource_field);
}
return $resource_field_collection;
}