src/Generator/Build.php
private function getJSONVersionOfSchema()
    {
        // Set cachefile
        $cacheFile = dirname(dirname(__DIR__)) . '/data/schemaorg.cache';

        if (!file_exists($cacheFile)) {
            // Create dir
            if (!file_exists(dirname($cacheFile))) {
                mkdir(dirname($cacheFile), 0777, true);
            }

            // Load RDFA Schema
            $graph = new \EasyRdf_Graph(self::RDFA_SCHEMA);
            $graph->load(self::RDFA_SCHEMA, 'rdfa');

            // Lookup the output format
            $format = \EasyRdf_Format::getFormat('jsonld');

            // Serialise to the new output format
            $output = $graph->serialise($format);

            if (!is_scalar($output)) {
                $output = var_export($output, true);
            }

            $this->schema = \ML\JsonLD\JsonLD::compact($graph->serialise($format), 'http://schema.org/');

            // Write cache file
            file_put_contents($cacheFile, serialize($this->schema));
        } else {
            $this->schema = unserialize(file_get_contents($cacheFile));
        }
    }
private function getJSONVersionOfSchema()
    {
        // Set cachefile
        $cacheFile = dirname(dirname(__DIR__)) . '/data/schemaorg.cache';

        if (!file_exists($cacheFile)) {
            // Create dir
            if (!file_exists(dirname($cacheFile))) {
                mkdir(dirname($cacheFile), 0777, true);
            }

            // Load RDFA Schema
            $graph = new \EasyRdf_Graph(self::RDFA_SCHEMA);
            $graph->load(self::RDFA_SCHEMA, 'rdfa');

            // Lookup the output format
            $format = \EasyRdf_Format::getFormat('jsonld');

            // Serialise to the new output format
            $output = $graph->serialise($format);

            if (!is_scalar($output)) {
                $output = var_export($output, true);
            }

            $this->schema = \ML\JsonLD\JsonLD::compact($graph->serialise($format), 'http://schema.org/');

            // Write cache file
            file_put_contents($cacheFile, serialize($this->schema));
        } else {
            $this->schema = unserialize(file_get_contents($cacheFile));
        }
    }
private function getJSONVersionOfSchema ( ) { // Set cachefile $ cacheFile = dirname ( dirname ( __DIR__ ) ) . '/data/schemaorg.cache' ; if ( ! file_exists ( $ cacheFile ) ) { // Create dir if ( ! file_exists ( dirname ( $ cacheFile ) ) ) { mkdir ( dirname ( $ cacheFile ) , 0777 , true ) ; } // Load RDFA Schema $ graph = new \ EasyRdf_Graph ( self :: RDFA_SCHEMA ) ; $ graph -> load ( self :: RDFA_SCHEMA , 'rdfa' ) ; // Lookup the output format $ format = \ EasyRdf_Format :: getFormat ( 'jsonld' ) ; // Serialise to the new output format $ output = $ graph -> serialise ( $ format ) ; if ( ! is_scalar ( $ output ) ) { $ output = var_export ( $ output , true ) ; } $ this -> schema = \ ML \ JsonLD \ JsonLD :: compact ( $ graph -> serialise ( $ format ) , 'http://schema.org/' ) ; // Write cache file file_put_contents ( $ cacheFile , serialize ( $ this -> schema ) ) ; } else { $ this -> schema = unserialize ( file_get_contents ( $ cacheFile ) ) ; } }
Retrieve the latest RDFA version of schema.org and converts it to JSON-LD.

Note: caches the file in data and retrieves it from there as long as it exists.
Retrieve the latest RDFA version of schema . org and converts it to JSON - LD .