comparison core/modules/jsonapi/src/JsonApiResource/ResourceIdentifierTrait.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
1 <?php
2
3 namespace Drupal\jsonapi\JsonApiResource;
4
5 /**
6 * Used to associate an object like an exception to a particular resource.
7 *
8 * @internal JSON:API maintains no PHP API. The API is the HTTP API. This class
9 * may change at any time and could break any dependencies on it.
10 *
11 * @see https://www.drupal.org/project/jsonapi/issues/3032787
12 * @see jsonapi.api.php
13 *
14 * @see \Drupal\jsonapi\JsonApiResource\ResourceIdentifierInterface
15 */
16 trait ResourceIdentifierTrait {
17
18 /**
19 * A ResourceIdentifier object.
20 *
21 * @var \Drupal\jsonapi\JsonApiResource\ResourceIdentifier
22 */
23 protected $resourceIdentifier;
24
25 /**
26 * The JSON:API resource type of of the identified resource object.
27 *
28 * @var \Drupal\jsonapi\ResourceType\ResourceType
29 */
30 protected $resourceType;
31
32 /**
33 * {@inheritdoc}
34 */
35 public function getId() {
36 return $this->resourceIdentifier->getId();
37 }
38
39 /**
40 * {@inheritdoc}
41 */
42 public function getTypeName() {
43 return $this->resourceIdentifier->getTypeName();
44 }
45
46 /**
47 * {@inheritdoc}
48 */
49 public function getResourceType() {
50 if (!isset($this->resourceType)) {
51 $this->resourceType = $this->resourceIdentifier->getResourceType();
52 }
53 return $this->resourceType;
54 }
55
56 }