diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityNormalizer.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityNormalizer.php index c0d06aa..9c30d1e 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityNormalizer.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityNormalizer.php @@ -28,12 +28,12 @@ class JsonldEntityNormalizer extends JsonldNormalizerBase implements Denormalize * Implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize() */ public function normalize($entity, $format = NULL) { - $entityWrapper = new JsonldEntityWrapper($entity, $format, $this->serializer, $this->siteSchemaManager); + $entity_wrapper = new JsonldEntityWrapper($entity, $format, $this->serializer, $this->siteSchemaManager); - $attributes = $entityWrapper->getProperties(); + $attributes = $entity_wrapper->getProperties(); $attributes = array( - '@id' => $entityWrapper->getId(), - '@type' => $entityWrapper->getTypeUri(), + '@id' => $entity_wrapper->getId(), + '@type' => $entity_wrapper->getTypeUri(), ) + $attributes; return $attributes; } @@ -52,20 +52,20 @@ public function denormalize($data, $class, $format = null) { // either include a type URI from this site's schema, or one of the type // URIs in the incoming data must map to a site schema URI when passed // through the RDF mapping manager. - $typeUris = is_array($data['@type']) ? $data['@type'] : array($data['@type']); + $type_uris = is_array($data['@type']) ? $data['@type'] : array($data['@type']); // If the RDF mapping manager can find a match to a site schema URI, it // will return the corresponding Typed Data ids. Otherwise, throw an // exception. // @todo The @types might be CURIEs or aliases. Expand before trying to map. try { - $typedDataIds = $this->rdfMappingManager->getTypedDataIdsFromTypeUris($typeUris); + $typed_data_ids = $this->rdfMappingManager->getTypedDataIdsFromTypeUris($type_uris); } catch (RdfMappingException $e) { throw new UnexpectedValueException($e->getMessage(), 0, $e); } $values = array( - 'type' => $typedDataIds['bundle'], + 'type' => $typed_data_ids['bundle'], ); // If the data specifies a default language, use it to create the entity. if (isset($data['langcode'])) { @@ -78,7 +78,7 @@ public function denormalize($data, $class, $format = null) { else if ($this->containsTranslation($data)) { $values['langcode'] = language(LANGUAGE_TYPE_CONTENT)->langcode; } - $entity = entity_create($typedDataIds['entity_type'], $values); + $entity = entity_create($typed_data_ids['entity_type'], $values); // For each attribute in the JSON-LD, add the values as fields to the newly // created entity. It is assumed that the JSON attribute names are the same diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityReferenceNormalizer.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityReferenceNormalizer.php index 723b90c..66767cf 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityReferenceNormalizer.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityReferenceNormalizer.php @@ -36,9 +36,9 @@ public function normalize($object, $format = NULL) { // of creating the array of properties, we could simply call normalize and // pass in the referenced entity with a flag that ensures it is rendered as // a node reference and not a node definition. - $entityWrapper = new JsonldEntityWrapper($object->entity, $format, $this->serializer, $this->siteSchemaManager); + $entity_wrapper = new JsonldEntityWrapper($object->entity, $format, $this->serializer, $this->siteSchemaManager); return array( - '@id' => $entityWrapper->getId(), + '@id' => $entity_wrapper->getId(), ); } diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php index 19c7514..a2e49e3 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php @@ -61,14 +61,14 @@ class JsonldEntityWrapper { * The format. * @param \Symfony\Component\Serializer\Serializer $serializer * The serializer, provided by the SerializerAwareNormaizer. - * @param \Drupal\rdf\SiteSchema\SiteSchemaManager $siteSchemaManager + * @param \Drupal\rdf\SiteSchema\SiteSchemaManager $site_schema_manager * The site schema manager. */ - public function __construct(Entity $entity, $format, Serializer $serializer, SiteSchemaManager $siteSchemaManager) { + public function __construct(Entity $entity, $format, Serializer $serializer, SiteSchemaManager $site_schema_manager) { $this->entity = $entity; $this->format = $format; $this->serializer = $serializer; - $this->siteSchemaManager = $siteSchemaManager; + $this->siteSchemaManager = $site_schema_manager; } /** diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldNormalizerBase.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldNormalizerBase.php index b3774e0..e898da8 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldNormalizerBase.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/JsonldNormalizerBase.php @@ -49,14 +49,14 @@ /** * Constructor. * - * @param \Drupal\rdf\SiteSchema\SiteSchemaManager $siteSchemaManager + * @param \Drupal\rdf\SiteSchema\SiteSchemaManager $site_schema_manager * The site schema manager. - * @param \Drupal\rdf\RdfMappingManager $rdfMappingManager + * @param \Drupal\rdf\RdfMappingManager $rdf_mapping_manager * The RDF mapping manager. */ - public function __construct(SiteSchemaManager $siteSchemaManager, RdfMappingManager $rdfMappingManager) { - $this->siteSchemaManager = $siteSchemaManager; - $this->rdfMappingManager = $rdfMappingManager; + public function __construct(SiteSchemaManager $site_schema_manager, RdfMappingManager $rdf_mapping_manager) { + $this->siteSchemaManager = $site_schema_manager; + $this->rdfMappingManager = $rdf_mapping_manager; } /** diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldRdfSchemaNormalizer.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldRdfSchemaNormalizer.php index 0196dcf..2834c61 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldRdfSchemaNormalizer.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/JsonldRdfSchemaNormalizer.php @@ -29,7 +29,7 @@ public function normalize($data, $format = NULL) { $normalized = array(); $graph = $data->getGraph(); - foreach ($graph as $termUri => $properties) { + foreach ($graph as $term_uri => $properties) { // JSON-LD uses the @type keyword as a stand-in for rdf:type. Replace any // use of rdf:type and move the type to the front of the property array. if (isset($properties[RdfConstants::RDF_TYPE])) { @@ -41,7 +41,7 @@ public function normalize($data, $format = NULL) { // Add the @id keyword to the front of the array. $normalized[] = array( - '@id' => $termUri, + '@id' => $term_uri, ) + $properties; } diff --git a/core/modules/jsonld/lib/Drupal/jsonld/Tests/NormalizeDenormalizeTest.php b/core/modules/jsonld/lib/Drupal/jsonld/Tests/NormalizeDenormalizeTest.php index 44bd3173..a9e057d 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/Tests/NormalizeDenormalizeTest.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/Tests/NormalizeDenormalizeTest.php @@ -51,8 +51,8 @@ public static function getInfo() { function setUp() { parent::setUp(); - $setupHelper = new JsonldTestSetupHelper(); - $this->normalizers = $setupHelper->getNormalizers(); + $setup_helper = new JsonldTestSetupHelper(); + $this->normalizers = $setup_helper->getNormalizers(); // Add German as a language. $language = new Language(array( @@ -142,9 +142,9 @@ public function testNormalize() { function testDenormalize() { $schema = new SiteSchema(SiteSchema::CONTENT_DEPLOYMENT); - $bundleUri = $schema->bundle('entity_test', 'entity_test')->getUri(); - $incomingData = array( - '@type' => $bundleUri, + $bundle_uri = $schema->bundle('entity_test', 'entity_test')->getUri(); + $incoming_data = array( + '@type' => $bundle_uri, 'name' => array( 'en' => array( array( @@ -168,16 +168,16 @@ function testDenormalize() { ); // Test valid request. - $entity = $this->normalizers['entity']->denormalize($incomingData, 'Drupal\Core\Entity\EntityNG', static::$format); + $entity = $this->normalizers['entity']->denormalize($incoming_data, 'Drupal\Core\Entity\EntityNG', static::$format); $this->assertEqual('entity_test', $entity->bundle(), "Denormalize creates entity with correct bundle."); - $this->assertEqual($incomingData['name']['en'], $entity->get('name')->getValue(), "Translatable field denormalized correctly in default language."); - $this->assertEqual($incomingData['name']['de'], $entity->getTranslation('de')->get('name')->getValue(), "Translatable field denormalized correctly in translation language."); - $this->assertEqual($incomingData['field_test_text']['und'], $entity->get('field_test_text')->getValue(), "Untranslatable field denormalized correctly."); + $this->assertEqual($incoming_data['name']['en'], $entity->get('name')->getValue(), "Translatable field denormalized correctly in default language."); + $this->assertEqual($incoming_data['name']['de'], $entity->getTranslation('de')->get('name')->getValue(), "Translatable field denormalized correctly in translation language."); + $this->assertEqual($incoming_data['field_test_text']['und'], $entity->get('field_test_text')->getValue(), "Untranslatable field denormalized correctly."); // Test request without @type. - unset($incomingData['@type']); + unset($incoming_data['@type']); try { - $this->normalizers['entity']->denormalize($incomingData, 'Drupal\Core\Entity\EntityNG', static::$format); + $this->normalizers['entity']->denormalize($incoming_data, 'Drupal\Core\Entity\EntityNG', static::$format); $this->fail('Trying to denormalize entity data without @type results in exception.'); } catch (UnexpectedValueException $e) { @@ -185,9 +185,9 @@ function testDenormalize() { } // Test request with @type that has no valid mapping. - $incomingData['@type'] = 'http://failing-uri.com/type'; + $incoming_data['@type'] = 'http://failing-uri.com/type'; try { - $this->normalizers['entity']->denormalize($incomingData, 'Drupal\Core\Entity\EntityNG', static::$format); + $this->normalizers['entity']->denormalize($incoming_data, 'Drupal\Core\Entity\EntityNG', static::$format); $this->fail('Trying to denormalize entity data with unrecognized @type results in exception.'); } catch (UnexpectedValueException $e) { diff --git a/core/modules/jsonld/lib/Drupal/jsonld/Tests/RdfSchemaSerializationTest.php b/core/modules/jsonld/lib/Drupal/jsonld/Tests/RdfSchemaSerializationTest.php index 27a8d79..c4422aa 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/Tests/RdfSchemaSerializationTest.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/Tests/RdfSchemaSerializationTest.php @@ -31,25 +31,25 @@ function testSchemaSerialization() { // is enabled. $this->enableModules(array('system')); - $entityType = $bundle = 'entity_test'; + $entity_type = $bundle = 'entity_test'; // Set up the bundle schema for the entity_test bundle. $schema = new SiteSchema(SiteSchema::CONTENT_DEPLOYMENT); - $bundleSchema = $schema->bundle($entityType, $bundle); + $bundle_schema = $schema->bundle($entity_type, $bundle); // Set up the serializer. - $setupHelper = new JsonldTestSetupHelper(); - $normalizer = new JsonldRdfSchemaNormalizer($setupHelper->getSiteSchemaManager(), $setupHelper->getRdfMappingManager()); + $setup_helper = new JsonldTestSetupHelper(); + $normalizer = new JsonldRdfSchemaNormalizer($setup_helper->getSiteSchemaManager(), $setup_helper->getRdfMappingManager()); $serializer = new Serializer(array($normalizer), array(new JsonldEncoder())); - $serialized = $serializer->serialize($bundleSchema, 'jsonld'); + $serialized = $serializer->serialize($bundle_schema, 'jsonld'); $decoded = json_decode($serialized); - $parsedTerm = $decoded[0]; + $parsed_term = $decoded[0]; - $this->assertEqual($parsedTerm->{'@id'}, $bundleSchema->getUri(), 'JSON-LD for schema term uses correct @id.'); - $this->assertEqual($parsedTerm->{'@type'}, 'http://www.w3.org/2000/01/rdf-schema#class', 'JSON-LD for schema term uses correct @type.'); + $this->assertEqual($parsed_term->{'@id'}, $bundle_schema->getUri(), 'JSON-LD for schema term uses correct @id.'); + $this->assertEqual($parsed_term->{'@type'}, 'http://www.w3.org/2000/01/rdf-schema#class', 'JSON-LD for schema term uses correct @type.'); // The @id and @type should be placed in the beginning of the array. - $arrayKeys = array_keys((array) $parsedTerm); - $this->assertEqual(array('@id', '@type'), array_slice($arrayKeys, 0, 2), 'JSON-LD keywords are placed before other properties.'); - $this->assertTrue(isset($parsedTerm->{'http://www.w3.org/2000/01/rdf-schema#isDefinedBy'}), 'Other properties of the term are included.'); + $array_keys = array_keys((array) $parsed_term); + $this->assertEqual(array('@id', '@type'), array_slice($array_keys, 0, 2), 'JSON-LD keywords are placed before other properties.'); + $this->assertTrue(isset($parsed_term->{'http://www.w3.org/2000/01/rdf-schema#isDefinedBy'}), 'Other properties of the term are included.'); } } diff --git a/core/modules/jsonld/lib/Drupal/jsonld/Tests/SupportsSerializationTest.php b/core/modules/jsonld/lib/Drupal/jsonld/Tests/SupportsSerializationTest.php index f4ac546..38cee8a 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/Tests/SupportsSerializationTest.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/Tests/SupportsSerializationTest.php @@ -46,8 +46,8 @@ public static function getInfo() { function setUp() { parent::setUp(); - $setupHelper = new JsonldTestSetupHelper(); - $this->normalizers = $setupHelper->getNormalizers(); + $setup_helper = new JsonldTestSetupHelper(); + $this->normalizers = $setup_helper->getNormalizers(); } /** diff --git a/core/modules/rdf/lib/Drupal/rdf/EventSubscriber/MappingSubscriber.php b/core/modules/rdf/lib/Drupal/rdf/EventSubscriber/MappingSubscriber.php index de1d7e9..764c2f9 100644 --- a/core/modules/rdf/lib/Drupal/rdf/EventSubscriber/MappingSubscriber.php +++ b/core/modules/rdf/lib/Drupal/rdf/EventSubscriber/MappingSubscriber.php @@ -25,11 +25,11 @@ class MappingSubscriber implements EventSubscriberInterface { * The mapping event. */ public function mapTypesFromInput(\Drupal\rdf\MapTypesFromInputEvent $event) { - $inputUris = $event->getInputUris(); - $siteSchemaTypes = $event->getSiteSchemaTypes(); - foreach ($inputUris as $inputUri) { - if (isset($siteSchemaTypes[$inputUri])) { - $event->setSiteSchemaUri($inputUri); + $input_uris = $event->getInputUris(); + $site_schema_types = $event->getSiteSchemaTypes(); + foreach ($input_uris as $input_uri) { + if (isset($site_schema_types[$input_uri])) { + $event->setSiteSchemaUri($input_uri); $event->stopPropagation(); } } diff --git a/core/modules/rdf/lib/Drupal/rdf/EventSubscriber/RouteSubscriber.php b/core/modules/rdf/lib/Drupal/rdf/EventSubscriber/RouteSubscriber.php index 0c6d60a..123493b 100644 --- a/core/modules/rdf/lib/Drupal/rdf/EventSubscriber/RouteSubscriber.php +++ b/core/modules/rdf/lib/Drupal/rdf/EventSubscriber/RouteSubscriber.php @@ -29,11 +29,11 @@ class RouteSubscriber implements EventSubscriberInterface { /** * Constructor. * - * @param \Drupal\rdf\SiteSchema\SiteSchemaManager $siteSchemaManager + * @param \Drupal\rdf\SiteSchema\SiteSchemaManager $site_schema_manager * The injected site schema manager. */ - public function __construct(SiteSchemaManager $siteSchemaManager) { - $this->siteSchemaManager = $siteSchemaManager; + public function __construct(SiteSchemaManager $site_schema_manager) { + $this->siteSchemaManager = $site_schema_manager; } /** @@ -50,10 +50,10 @@ public function routes(RouteBuildEvent $event) { foreach ($this->siteSchemaManager->getSchemas() as $schema) { $routes = $schema->getRoutes(); foreach ($routes as $controller => $pattern) { - $schemaPath = $schema->getPath(); + $schema_path = $schema->getPath(); $route = new Route($pattern, array( '_controller' => 'Drupal\rdf\SiteSchema\SchemaController::' . $controller, - 'schema_path' => $schemaPath, + 'schema_path' => $schema_path, ), array( '_method' => 'GET', '_access' => 'TRUE', @@ -61,8 +61,8 @@ public function routes(RouteBuildEvent $event) { // Create the route name to use in the RouteCollection. Remove the // trailing slash and replace characters, so that a path such as // site-schema/syndication/ becomes rdf.site_schema.syndication. - $routeName = 'rdf.' . str_replace(array('-','/'), array('_', '.'), substr_replace($schemaPath ,"",-1)); - $collection->add($routeName, $route); + $route_name = 'rdf.' . str_replace(array('-','/'), array('_', '.'), substr_replace($schema_path ,"",-1)); + $collection->add($route_name, $route); } } } diff --git a/core/modules/rdf/lib/Drupal/rdf/MapTypesFromInputEvent.php b/core/modules/rdf/lib/Drupal/rdf/MapTypesFromInputEvent.php index 6b0e841..c54fe0d 100644 --- a/core/modules/rdf/lib/Drupal/rdf/MapTypesFromInputEvent.php +++ b/core/modules/rdf/lib/Drupal/rdf/MapTypesFromInputEvent.php @@ -38,14 +38,14 @@ class MapTypesFromInputEvent extends Event { /** * Constructor. * - * @param $inputUris + * @param $input_uris * An array of incoming RDF type URIs. - * @param $siteSchemaTypes + * @param $site_schema_types * An array of entity_type/bundles, keyed by site schema type URI. */ - public function __construct($inputUris, $siteSchemaTypes) { - $this->inputUris = $inputUris; - $this->siteSchemaTypes = $siteSchemaTypes; + public function __construct($input_uris, $site_schema_types) { + $this->inputUris = $input_uris; + $this->siteSchemaTypes = $site_schema_types; $this->siteSchemaUri = FALSE; } diff --git a/core/modules/rdf/lib/Drupal/rdf/RdfMappingManager.php b/core/modules/rdf/lib/Drupal/rdf/RdfMappingManager.php index c34cdd7..90588e9 100644 --- a/core/modules/rdf/lib/Drupal/rdf/RdfMappingManager.php +++ b/core/modules/rdf/lib/Drupal/rdf/RdfMappingManager.php @@ -40,18 +40,18 @@ class RdfMappingManager { * * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher * The event dispatcher. - * @param \Drupal\rdf\SiteSchema\SiteSchemaManager $siteSchemaManager + * @param \Drupal\rdf\SiteSchema\SiteSchemaManager $site_schema_manager * The site schema manager. */ - public function __construct(EventDispatcherInterface $dispatcher, SiteSchemaManager $siteSchemaManager) { + public function __construct(EventDispatcherInterface $dispatcher, SiteSchemaManager $site_schema_manager) { $this->dispatcher = $dispatcher; - $this->siteSchemaManager = $siteSchemaManager; + $this->siteSchemaManager = $site_schema_manager; } /** * Convert an array of RDF type URIs to the corresponding TypedData IDs. * - * @param array $inputRdfTypes + * @param array $input_rdf_types * An array of URIs for the type. * * @return array @@ -59,36 +59,36 @@ public function __construct(EventDispatcherInterface $dispatcher, SiteSchemaMana * * @throws \Drupal\rdf\RdfMappingException */ - public function getTypedDataIdsFromTypeUris($inputRdfTypes) { + public function getTypedDataIdsFromTypeUris($input_rdf_types) { // Get the cache of site schema types. - $siteSchemaTypes = $this->siteSchemaManager->getTypes(); + $site_schema_types = $this->siteSchemaManager->getTypes(); // Map the RDF type from the incoming data to an RDF type defined in the // internal site schema. - $typeUri = $this->mapTypesFromInput($inputRdfTypes); + $type_uri = $this->mapTypesFromInput($input_rdf_types); // If no site schema URI has been determined, then it's impossible to know // what entity type to create. Throw an exception. - if ($typeUri == FALSE) { - throw new RdfMappingException(sprintf('No mapping to a site schema type URI found for incoming types (%s).', implode(',', $inputRdfTypes))); + if ($type_uri == FALSE) { + throw new RdfMappingException(sprintf('No mapping to a site schema type URI found for incoming types (%s).', implode(',', $input_rdf_types))); } // Use the mapped RDF type URI to get the TypedData API ids the rest of the // system uses (entity type and bundle). - return $siteSchemaTypes[$typeUri]; + return $site_schema_types[$type_uri]; } /** * Map an array of incoming URIs to an internal site schema URI. * - * @param array $inputRdfTypes + * @param array $input_rdf_types * An array of RDF type URIs. * * @return string * The corresponding site schema type URI. */ - protected function mapTypesFromInput($inputRdfTypes) { + protected function mapTypesFromInput($input_rdf_types) { // Create the event using the array of incoming RDF type URIs and the cache // of internal site schema URIs. - $siteSchemaTypes = $this->siteSchemaManager->getTypes(); - $mapping_event = new MapTypesFromInputEvent($inputRdfTypes, $siteSchemaTypes); + $site_schema_types = $this->siteSchemaManager->getTypes(); + $mapping_event = new MapTypesFromInputEvent($input_rdf_types, $site_schema_types); // Allow other modules to map the incoming type URIs to an internal site // schema type URI. For example, a content deployment module could take diff --git a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/BundleSchema.php b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/BundleSchema.php index 7c9196d..2c92696 100644 --- a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/BundleSchema.php +++ b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/BundleSchema.php @@ -32,15 +32,15 @@ class BundleSchema extends EntitySchema { /** * Constructor. * - * @param \Drupal\rdf\SiteSchema\SiteSchema $siteSchema + * @param \Drupal\rdf\SiteSchema\SiteSchema $site_schema * The schema the term is defined in. * @param string $entity_type * The entity type. * @param string $bundle * The bundle. */ - public function __construct($siteSchema, $entity_type, $bundle) { - parent::__construct($siteSchema, $entity_type); + public function __construct($site_schema, $entity_type, $bundle) { + parent::__construct($site_schema, $entity_type); $this->bundle = $bundle; } diff --git a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/EntitySchema.php b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/EntitySchema.php index ec72219..48a69fc 100644 --- a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/EntitySchema.php +++ b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/EntitySchema.php @@ -32,13 +32,13 @@ class EntitySchema extends SchemaTermBase { /** * Constructor. * - * @param \Drupal\rdf\SiteSchema\SiteSchema $siteSchema + * @param \Drupal\rdf\SiteSchema\SiteSchema $site_schema * The schema the term is defined in. * @param string $entity_type * The entity type. */ - public function __construct($siteSchema, $entity_type) { - parent::__construct($siteSchema); + public function __construct($site_schema, $entity_type) { + parent::__construct($site_schema); $this->entityType = $entity_type; } diff --git a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SchemaController.php b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SchemaController.php index 93abb9d..b60eb84 100644 --- a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SchemaController.php +++ b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SchemaController.php @@ -59,8 +59,8 @@ public function bundle($entity_type, $bundle, $schema_path) { } $serializer = $this->container->get('serializer'); - $siteSchemaManager = $this->container->get('rdf.site_schema_manager'); - $schema = $siteSchemaManager->getSchema($schema_path); + $site_schema_manager = $this->container->get('rdf.site_schema_manager'); + $schema = $site_schema_manager->getSchema($schema_path); // @todo Remove hard-coded mimetype once we have proper conneg. $content = $serializer->serialize($schema->bundle($entity_type, $bundle), 'jsonld'); return new Response($content, 200, array('Content-type' => 'application/json')); diff --git a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SchemaTermBase.php b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SchemaTermBase.php index abff580..d7afd1c 100644 --- a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SchemaTermBase.php +++ b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SchemaTermBase.php @@ -31,11 +31,11 @@ /** * Constructor. * - * @param \Drupal\rdf\SiteSchema\SiteSchema $siteSchema + * @param \Drupal\rdf\SiteSchema\SiteSchema $site_schema * The namespace. */ - public function __construct($siteSchema) { - $this->siteSchema = $siteSchema; + public function __construct($site_schema) { + $this->siteSchema = $site_schema; } /** diff --git a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SiteSchema.php b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SiteSchema.php index c393b26..e3153d1 100644 --- a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SiteSchema.php +++ b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SiteSchema.php @@ -32,17 +32,17 @@ class SiteSchema { /** * Constructor. * - * @param string $schemaPath + * @param string $schema_path * The schema path constant, used to determine which schema to instantiate. * * @throws \UnexpectedValueException */ - public function __construct($schemaPath) { + public function __construct($schema_path) { $valid_paths = array(self::CONTENT_DEPLOYMENT, self::SYNDICATION); - if (!in_array($schemaPath, $valid_paths)) { - throw new \UnexpectedValueException(sprintf('%s is not a valid site schema path. Schema path must be one of %s.'), $schemaPath, implode(', ', $valid_paths)); + if (!in_array($schema_path, $valid_paths)) { + throw new \UnexpectedValueException(sprintf('%s is not a valid site schema path. Schema path must be one of %s.'), $schema_path, implode(', ', $valid_paths)); } - $this->schemaPath = $schemaPath; + $this->schemaPath = $schema_path; } /** diff --git a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SiteSchemaManager.php b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SiteSchemaManager.php index 639b221..7ca9ca8 100644 --- a/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SiteSchemaManager.php +++ b/core/modules/rdf/lib/Drupal/rdf/SiteSchema/SiteSchemaManager.php @@ -38,19 +38,19 @@ public function writeCache() { // Type URIs correspond to bundles. Iterate through the bundles to get the // URI and data for them. - foreach (entity_get_info() as $entityType => $entityInfo) { + foreach (entity_get_info() as $entity_type => $entity_info) { // Only content entities are supported currently. // @todo Consider supporting config entities. - $reflection = new ReflectionClass($entityInfo['class']); + $reflection = new ReflectionClass($entity_info['class']); if ($reflection->implementsInterface('\Drupal\Core\Config\Entity\ConfigEntityInterface')) { continue; } - foreach ($entityInfo['bundles'] as $bundle => $bundleInfo) { + foreach ($entity_info['bundles'] as $bundle => $bundle_info) { // Get a type URI for the bundle in each of the defined schemas. foreach ($this->siteSchemas as $schema) { - $bundleUri = $schema->bundle($entityType, $bundle)->getUri(); - $data[$bundleUri] = array( - 'entity_type' => $entityType, + $bundle_uri = $schema->bundle($entity_type, $bundle)->getUri(); + $data[$bundle_uri] = array( + 'entity_type' => $entity_type, 'bundle' => $bundle, ); } @@ -65,8 +65,8 @@ public function getSchemas() { return $this->siteSchemas; } - public function getSchema($schemaPath) { - return $this->siteSchemas[$schemaPath]; + public function getSchema($schema_path) { + return $this->siteSchemas[$schema_path]; } /** diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfMappingEventTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfMappingEventTest.php index d71a652..7a7a7b5 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfMappingEventTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfMappingEventTest.php @@ -45,20 +45,20 @@ public function testMapInputType() { $dispatcher = new EventDispatcher(); $dispatcher->addSubscriber(new MappingSubscriber()); $dispatcher->addSubscriber(new TestMappingSubscriber()); - $siteSchemaManager = new SiteSchemaManager(new DatabaseBackend('cache')); - $mappingManager = new RdfMappingManager($dispatcher, $siteSchemaManager); + $site_schema_manager = new SiteSchemaManager(new DatabaseBackend('cache')); + $mapping_manager = new RdfMappingManager($dispatcher, $site_schema_manager); // Test that a site schema URI is mapped to itself. This is the default // behavior. $schema = new SiteSchema(SiteSchema::CONTENT_DEPLOYMENT); - $bundleSchema = $schema->bundle('entity_test', 'entity_test'); - $siteSchemaType = $bundleSchema->getUri(); - $typedDataIds = $mappingManager->getTypedDataIdsFromTypeUris(array($siteSchemaType)); - $this->assertTrue($typedDataIds['bundle'] == 'entity_test', 'An internal site schema type URI is properly handled.'); + $bundle_schema = $schema->bundle('entity_test', 'entity_test'); + $site_schema_type = $bundle_schema->getUri(); + $typed_data_ids = $mapping_manager->getTypedDataIdsFromTypeUris(array($site_schema_type)); + $this->assertTrue($typed_data_ids['bundle'] == 'entity_test', 'An internal site schema type URI is properly handled.'); // Test that a module can map an external URI to a site schema URI. - $typedDataIds = $mappingManager->getTypedDataIdsFromTypeUris(array(TestMappingSubscriber::STAGING_SITE_TYPE_URI)); - $this->assertTrue($typedDataIds['bundle'] == 'entity_test', 'Modules can map external type URIs to a site schema type.'); + $typed_data_ids = $mapping_manager->getTypedDataIdsFromTypeUris(array(TestMappingSubscriber::STAGING_SITE_TYPE_URI)); + $this->assertTrue($typed_data_ids['bundle'] == 'entity_test', 'Modules can map external type URIs to a site schema type.'); } } diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/SiteSchemaTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/SiteSchemaTest.php index fd1bb19..0cfe07f 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/SiteSchemaTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/SiteSchemaTest.php @@ -35,21 +35,21 @@ public static function getInfo() { * Tests site-generated schema. */ function testSiteSchema() { - $entityType = $bundle = 'entity_test'; + $entity_type = $bundle = 'entity_test'; $schema = new SiteSchema(SiteSchema::SYNDICATION); - $schemaPath = 'site-schema/syndication/'; + $schema_path = 'site-schema/syndication/'; // Bundle. - $bundleSchema = $schema->bundle($entityType, $bundle); - $bundleUri = url("$schemaPath$entityType/$bundle", array('absolute' => TRUE)); - $bundleProperties = array( - 'http://www.w3.org/2000/01/rdf-schema#isDefinedBy' => url($schemaPath, array('absolute' => TRUE)), + $bundle_schema = $schema->bundle($entity_type, $bundle); + $bundle_uri = url("$schema_path$entity_type/$bundle", array('absolute' => TRUE)); + $bundle_properties = array( + 'http://www.w3.org/2000/01/rdf-schema#isDefinedBy' => url($schema_path, array('absolute' => TRUE)), 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' => 'http://www.w3.org/2000/01/rdf-schema#class', - 'http://www.w3.org/2000/01/rdf-schema#subClassOf' => url("$schemaPath$entityType", array('absolute' => TRUE)), + 'http://www.w3.org/2000/01/rdf-schema#subClassOf' => url("$schema_path$entity_type", array('absolute' => TRUE)), ); - $this->assertEqual($bundleSchema->getUri(), $bundleUri, 'Bundle term URI is generated correctly.'); - $this->assertEqual($bundleSchema->getProperties(), $bundleProperties, 'Bundle term properties are generated correctly.'); + $this->assertEqual($bundle_schema->getUri(), $bundle_uri, 'Bundle term URI is generated correctly.'); + $this->assertEqual($bundle_schema->getProperties(), $bundle_properties, 'Bundle term properties are generated correctly.'); } } diff --git a/core/modules/rdf/tests/rdf_test_mapping/lib/Drupal/rdf_test_mapping/EventSubscriber/TestMappingSubscriber.php b/core/modules/rdf/tests/rdf_test_mapping/lib/Drupal/rdf_test_mapping/EventSubscriber/TestMappingSubscriber.php index 1141615..44e9460 100644 --- a/core/modules/rdf/tests/rdf_test_mapping/lib/Drupal/rdf_test_mapping/EventSubscriber/TestMappingSubscriber.php +++ b/core/modules/rdf/tests/rdf_test_mapping/lib/Drupal/rdf_test_mapping/EventSubscriber/TestMappingSubscriber.php @@ -23,26 +23,26 @@ class TestMappingSubscriber implements EventSubscriberInterface { * The mapping event. */ public function mapTypesFromInput($event) { - $inputUris = $event->getInputUris(); - $siteSchemaTypes = $event->getSiteSchemaTypes(); + $input_uris = $event->getInputUris(); + $site_schema_types = $event->getSiteSchemaTypes(); // This mapping between an external type and a site schema type would be // managed by something in the implementing module, such as a database // table. For the test, manually map a fake external URI to the site schema // URI for the test entity. $schema = new SiteSchema(SiteSchema::CONTENT_DEPLOYMENT); - $bundleSchema = $schema->bundle('entity_test', 'entity_test'); - $siteSchemaType = $bundleSchema->getUri(); + $bundle_schema = $schema->bundle('entity_test', 'entity_test'); + $site_schema_type = $bundle_schema->getUri(); $mapping = array( - self::STAGING_SITE_TYPE_URI => $siteSchemaType, + self::STAGING_SITE_TYPE_URI => $site_schema_type, ); - foreach ($inputUris as $inputUri) { + foreach ($input_uris as $input_uri) { // If the incoming URI is mapped in the mapping array, and the value of // that mapping is found in the cache of site schema types, then set the // site schema URI. - if (isset($mapping[$inputUri]) && isset($siteSchemaTypes[$mapping[$inputUri]])) { - $event->setSiteSchemaUri($mapping[$inputUri]); + if (isset($mapping[$input_uri]) && isset($site_schema_types[$mapping[$input_uri]])) { + $event->setSiteSchemaUri($mapping[$input_uri]); } } }