Open Data Catalog v2.0.0
Drupal\common\Resource Class Reference
Inheritance diagram for Drupal\common\Resource:

Public Member Functions

 __construct ($file_path, $mime_type, $perspective=self::DEFAULT_SOURCE_PERSPECTIVE)
 createNewVersion ()
 createNewPerspective ($perspective, $uri)
 changeFilePath ($newPath)
 getIdentifier ()
 getFilePath ()
 getFolder ()
 getMimeType ()
 getVersion ()
 getPerspective ()
 getUniqueIdentifier ()
 jsonSerialize ()

Static Public Member Functions

static parseUniqueIdentifier (string $uid)
static getIdentifierAndVersion ($string)

Public Attributes


Detailed Description


A resource models a means to get data. URLs to data/files, API endpoints, paths to files stored locally in the server, are all possible forms of resources.

This class not only models a resource, but it helps model other properties necessary for other systems like the Drupal::metastore::ResourceMapper and Drupal::datastore::Service::ResourceLocalizer to enhance DKAN's capabilities around resources.

These properties are version and perspective.

For more details refer to the methods governing these behaviors:

  1. Resource::createNewVersion()
  2. Resource::createNewPerspective()

    Rename filePath to uri or url.

Definition at line 28 of file Resource.php.

Constructor & Destructor Documentation

◆ __construct()

Drupal\common\Resource::__construct (   $file_path,
  $perspective = self::DEFAULT_SOURCE_PERSPECTIVE 


Definition at line 42 of file Resource.php.

Member Function Documentation

◆ changeFilePath()

Drupal\common\Resource::changeFilePath (   $newPath)

Change file path.

Definition at line 92 of file Resource.php.

◆ createNewPerspective()

Drupal\common\Resource::createNewPerspective (   $perspective,

Create a new perspective.

Perspectives are useful to represent clusters of connected resources.

For example, a CSV file might also have an API endpoint that makes the data available. In this circumstance we could create the API endpoint resource as a new perspective of the file resource to make the system aware of the new resource, the API endpoint, and maintain the relatioship between the 2 resources.

Definition at line 83 of file Resource.php.

◆ createNewVersion()

Drupal\common\Resource::createNewVersion ( )

Create a new version.

Versions are, simply, a unique "string" used to represent changes in a resource. For example, when new data is added to a file/resource a new version of the resource should be created.

This class does not have any functionality that keeps track of changes in resources, it simply models the behavior to allow other parts of the system to create new versions of resources when they deem it necessary.

Definition at line 63 of file Resource.php.

◆ getFilePath()

Drupal\common\Resource::getFilePath ( )


Definition at line 118 of file Resource.php.

◆ getFolder()

Drupal\common\Resource::getFolder ( )


Definition at line 125 of file Resource.php.

◆ getIdentifier()

Drupal\common\Resource::getIdentifier ( )


Definition at line 111 of file Resource.php.

◆ getIdentifierAndVersion()

static Drupal\common\Resource::getIdentifierAndVersion (   $string)

Get Identifier and Version.

string$stringThe string given could be a unique identifier, or a partial identifier (no perspective), or a distribution uuid.

Definition at line 197 of file Resource.php.

◆ getMimeType()

Drupal\common\Resource::getMimeType ( )


Definition at line 132 of file Resource.php.

◆ getPerspective()

Drupal\common\Resource::getPerspective ( )


Definition at line 146 of file Resource.php.

◆ getUniqueIdentifier()

Drupal\common\Resource::getUniqueIdentifier ( )


Definition at line 153 of file Resource.php.

◆ getVersion()

Drupal\common\Resource::getVersion ( )


Definition at line 139 of file Resource.php.

◆ jsonSerialize()

Drupal\common\Resource::jsonSerialize ( )


Definition at line 162 of file Resource.php.

◆ parseUniqueIdentifier()

static Drupal\common\Resource::parseUniqueIdentifier ( string  $uid)

Parse unique identifier.

string$uidA string with the form <identifier>__<version>__perspective.
array An array keyed with identifier, version and perspective.

Definition at line 178 of file Resource.php.

Member Data Documentation


const Drupal\common\Resource::DEFAULT_SOURCE_PERSPECTIVE = 'source'

Definition at line 31 of file Resource.php.