diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityNormalizer.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityNormalizer.php index 3d0437d..f6cc9ed 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityNormalizer.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityNormalizer.php @@ -60,7 +60,7 @@ public function denormalize($data, $class, $format = null) { try { $typedDataIds = $this->rdfMappingManager->getTypedDataIds($typeUris); } catch (RdfMappingException $e) { - throw new UnexpectedValueException($e->getMessage()); + throw new UnexpectedValueException($e->getMessage(), 0, $e); } $values = array( diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php index 24027a3..4a5864a 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php @@ -89,17 +89,17 @@ public function getId() { * of simply returning the site schema URI. */ public function getTypeUri() { - $entityType = $this->entity->entityType(); + $entity_type = $this->entity->entityType(); $bundle = $this->entity->bundle(); switch ($this->format) { case 'drupal_jsonld': - $schemaPath = SiteSchema::CONTENT_DEPLOYMENT; + $schema_path = SiteSchema::CONTENT_DEPLOYMENT; break; case 'jsonld': - $schemaPath = SiteSchema::SYNDICATION; + $schema_path = SiteSchema::SYNDICATION; } - $schema = $this->siteSchemaManager->getSchema($schemaPath); - return $schema->bundle($entityType, $bundle)->getUri(); + $schema = $this->siteSchemaManager->getSchema($schema_path); + return $schema->bundle($entity_type, $bundle)->getUri(); } /** diff --git a/core/modules/rdf/lib/Drupal/rdf/RdfMappingException.php b/core/modules/rdf/lib/Drupal/rdf/RdfMappingException.php index f958e25..599ad1c 100644 --- a/core/modules/rdf/lib/Drupal/rdf/RdfMappingException.php +++ b/core/modules/rdf/lib/Drupal/rdf/RdfMappingException.php @@ -6,9 +6,7 @@ namespace Drupal\rdf; -use Exception; - /** * Exception to use when no RDF mapping is found. */ -class RdfMappingException extends Exception { } +class RdfMappingException extends \Exception { } diff --git a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/BundleSchema.php b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/BundleSchema.php index 8277770..d799404 100644 --- a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/BundleSchema.php +++ b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/BundleSchema.php @@ -15,7 +15,12 @@ */ class BundleSchema extends EntitySchema { - const URI_PATTERN = '{entity_type}/{bundle}'; + /** + * The URI pattern for bundle site schema terms. + * + * @var string + */ + public static $uriPattern = '{entity_type}/{bundle}'; /** * The bundle that this term identifies. @@ -43,7 +48,7 @@ public function __construct($siteSchema, $entity_type, $bundle) { * Implements \Drupal\rdf\SiteSchema\SchemaTermBase::getUri(). */ public function getUri() { - $path = str_replace(array('{entity_type}', '{bundle}'), array($this->entityType, $this->bundle), self::URI_PATTERN); + $path = str_replace(array('{entity_type}', '{bundle}'), array($this->entityType, $this->bundle), static::$uriPattern); return $this->siteSchema->getUri() . $path; } diff --git a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/EntitySchema.php b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/EntitySchema.php index bc602ee..36ec5c4 100644 --- a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/EntitySchema.php +++ b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/EntitySchema.php @@ -15,7 +15,12 @@ */ class EntitySchema extends SchemaTermBase { - const URI_PATTERN = '{entity_type}'; + /** + * The URI pattern for entity site schema terms. + * + * @var string + */ + public static $uriPattern = '{entity_type}'; /** * The entity type that this term identifies. @@ -52,7 +57,7 @@ public function getGraph() { * Implements \Drupal\rdf\SiteSchema\SchemaTermBase::getUri(). */ public function getUri() { - $path = str_replace('{entity_type}', $this->entityType , self::URI_PATTERN); + $path = str_replace('{entity_type}', $this->entityType , static::$uriPattern); return $this->siteSchema->getUri() . $path; } diff --git a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SchemaTermBase.php b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SchemaTermBase.php index bc4165d..f24bf57 100644 --- a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SchemaTermBase.php +++ b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SchemaTermBase.php @@ -8,12 +8,18 @@ namespace Drupal\rdf\SiteSchema; use Drupal\rdf\RdfConstants; -use Drupal\rdf\SiteSchema\SiteSchema; /** * Base class to define an RDF term in a schema. */ -abstract class SchemaTermBase { +abstract class SchemaTermBase implements SchemaTermInterface { + + /** + * The URI pattern for this type of site schema term. + * + * @var string + */ + public static $uriPattern; /** * The schema in which this term is defined. @@ -33,17 +39,6 @@ public function __construct($siteSchema) { } /** - * Get the full graph of terms and properties to display. - * - * When an RDF term URI is dereferenced, it usually contains a description of - * the term in RDF. To make it easier to use this description, include - * information about all related terms. For example, when viewing the RDF - * description for the RDF class which corresponds to a Drupal bundle, data - * about its fields would also be included. - */ - abstract public function getGraph(); - - /** * Get the term properties. * * @return array @@ -55,15 +50,4 @@ public function getProperties() { ); } - /** - * Get the URI of the term. - * - * Implementations of this method will use the URI patterns defined in - * URI_PATTERN constants and replace placeholders with actual values. - * - * @return string - * The URI of the term. - */ - abstract public function getUri(); - } diff --git a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SchemaTermInterface.php b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SchemaTermInterface.php new file mode 100644 index 0000000..7b841f1 --- /dev/null +++ b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SchemaTermInterface.php @@ -0,0 +1,43 @@ + $this->schemaPath . BundleSchema::URI_PATTERN, + 'bundle' => $this->schemaPath . BundleSchema::$uriPattern, ); } }