"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.10/core/modules/jsonapi/src/JsonApiResource/ResourceIdentifierTrait.php" (26 Nov 2020, 1247 Bytes) of package /linux/www/drupal-8.9.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ResourceIdentifierTrait.php" see the Fossies "Dox" file reference documentation.

    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/drupal/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 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 }