public function DataProviderPlug::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
1 call to DataProviderPlug::view()
- DataProviderPlug::viewMultiple in src/
Plugin/ resource/ DataProvider/ DataProviderPlug.php - Read operation.
File
- src/
Plugin/ resource/ DataProvider/ DataProviderPlug.php, line 59 - Contains \Drupal\restful\Plugin\resource\DataProvider\DataProviderPlug.
Class
- DataProviderPlug
- Class DataProviderPlug.
Namespace
Drupal\restful\Plugin\resource\DataProviderCode
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;
}