You are here

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

Namespace

Drupal\rdfui

File

src/SchemaOrgConverter.php
View source
<?php

namespace Drupal\rdfui;


/**
 * Extracts details of RDF resources from Schema.org.
 */
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);
    }
  }

}

Classes

Namesort descending Description
SchemaOrgConverter Extracts details of RDF resources from Schema.org.