You are here

class SchemaOrgConverter in Schema.org configuration tool (RDF UI) 8

Extracts details of RDF resources from Schema.org.

Hierarchy

Expanded class hierarchy of SchemaOrgConverter

4 files declare their use of SchemaOrgConverter
ContentBuilderForm.php in rdf_builder/src/Form/ContentBuilderForm.php
EasyRdfConverterTest.php in src/Tests/EasyRdfConverterTest.php
FieldMappings.php in src/Form/FieldMappings.php
rdfui.install in ./rdfui.install

File

src/SchemaOrgConverter.php, line 9

Namespace

Drupal\rdfui
View source
class SchemaOrgConverter extends EasyRdfConverter {

  /**
   * Cache id.
   *
   * @var string
   */
  private $cid = 'schema.org_converter';

  /**
   * Constructor.
   */
  public function __construct() {
    parent::__construct();
    $this
      ->create();
  }

  /**
   * {@inheritdoc}
   */
  private function create() {
    $uri = "https://schema.org/version/latest/schemaorg-current-http.rdf";
    $type = "rdfa";
    if ($cache = \Drupal::cache()
      ->get($this->cid)) {

      // Fetch cached copy of graph & lists.
      $data = $cache->data;
      $this->graph = $data['graph'];
      $this->listProperties = $data['listProperties'];
      $this->listTypes = $data['listTypes'];
    }
    else {
      $this
        ->createGraph($uri, $type);
      $data = array(
        'graph' => $this->graph,
        'listProperties' => $this->listProperties,
        'listTypes' => $this->listTypes,
      );
      \Drupal::cache()
        ->set($this->cid, $data);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EasyRdfConverter::$graph protected property EasyRdf Graph of the loaded resource.
EasyRdfConverter::$listProperties protected property List of Properties specified in Schema.org as string.
EasyRdfConverter::$listTypes protected property List of Types specified in Schema.org as string.
EasyRdfConverter::addProperties private function Adds Property label to list.
EasyRdfConverter::addType private function Adds Type label to list.
EasyRdfConverter::createGraph protected function Creates an \EasyRdf\Graph object from the given URI.
EasyRdfConverter::description public function Gets the description of the resource.
EasyRdfConverter::getListProperties public function Gets a list of Schema.org properties.
EasyRdfConverter::getListTypes public function Gets a list of Schema.org types.
EasyRdfConverter::getProperties private function Recursive function to extract properties.
EasyRdfConverter::getRangeDataTypes public function Gets data types in range of the property.
EasyRdfConverter::getTypeProperties public function Extracts properties of a given type.
EasyRdfConverter::iterateGraph private function Identifies all types and properties of the graph separately.
EasyRdfConverter::label public function Gets label of the resource.
SchemaOrgConverter::$cid private property Cache id.
SchemaOrgConverter::create private function
SchemaOrgConverter::__construct public function Constructor. Overrides EasyRdfConverter::__construct