public function CacheDecoratedResource::view in RESTful 7.2
Basic implementation for view.
Parameters
string $path: The resource path.
Return value
array An array of structured data for the things being viewed.
Overrides ResourceDecoratorBase::view
File
- src/
Plugin/ resource/ Decorators/ CacheDecoratedResource.php, line 175 - Contains \Drupal\restful\Plugin\resource\Decorators\CacheDecoratedResource
Class
Namespace
Drupal\restful\Plugin\resource\DecoratorsCode
public function view($path) {
// TODO: This is duplicating the code from Resource::view
$ids = explode(static::IDS_SEPARATOR, $path);
// REST requires a canonical URL for every resource.
$canonical_path = $this
->getDataProvider()
->canonicalPath($path);
$this
->getRequest()
->getHeaders()
->add(HttpHeader::create('Link', $this
->versionedUrl($canonical_path, array(), FALSE) . '; rel="canonical"'));
// If there is only one ID then use 'view'. Else, use 'viewMultiple'. The
// difference between the two is that 'view' allows access denied
// exceptions.
if (count($ids) == 1) {
return array(
$this
->getDataProvider()
->view($ids[0]),
);
}
else {
return $this
->getDataProvider()
->viewMultiple($ids);
}
}