You are here

public function EasyRdfConverter::label in Schema.org configuration tool (RDF UI) 8

Gets label of the resource.

Parameters

string $uri: URI of the resource (eg: schema:Person).

Return value

string Label of the resource, if not shortened name.

File

src/EasyRdfConverter.php, line 237

Class

EasyRdfConverter
Extracts details of RDF resources from an RDFa document.

Namespace

Drupal\rdfui

Code

public function label($uri) {
  if (empty($uri)) {
    \Drupal::messenger()
      ->addStatus($this
      ->t("Invalid uri"));
    return NULL;
  }
  $label = $this->graph
    ->label($uri);
  if (!empty($label)) {
    return $label
      ->getValue();
  }
  $names = explode(":", $uri);
  return $names[1];
}