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