diff --git a/core/modules/rdf/lib/Drupal/rdf/Plugin/Core/Entity/RdfMapping.php b/core/modules/rdf/lib/Drupal/rdf/Plugin/Core/Entity/RdfMapping.php index d06a83d..0f772ff 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Plugin/Core/Entity/RdfMapping.php +++ b/core/modules/rdf/lib/Drupal/rdf/Plugin/Core/Entity/RdfMapping.php @@ -83,9 +83,7 @@ public function getBundleMapping() { if (isset($this->types)) { $types = $this->types; } - return array( - 'types' => $types, - ); + return array('types' => $types); } /** @@ -184,7 +182,7 @@ public function getExportProperties() { 'targetEntityType', 'bundle', 'types', - 'fieldMappings' + 'fieldMappings', ); $properties = array(); foreach ($names as $name) { @@ -193,4 +191,4 @@ public function getExportProperties() { return $properties; } -} \ No newline at end of file +} diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php index d4038fb..e3e5c22 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php @@ -2,7 +2,7 @@ /** * @file - * Contains Drupal\rdf\Tests\CommentAttributesTest. + * Contains \Drupal\rdf\Tests\CommentAttributesTest. */ namespace Drupal\rdf\Tests; @@ -326,6 +326,9 @@ function _testBasicCommentRdfaMarkup($graph, $comment, $account = array()) { * array of values to set contact info. * @param $pid * Comment id of the parent comment in a thread. + * + * @return \Drupal\comment\Plugin\Core\Entity\Comment + * The saved comment. */ function saveComment($nid, $uid, $contact = NULL, $pid = 0) { $values = array( @@ -344,5 +347,5 @@ function saveComment($nid, $uid, $contact = NULL, $pid = 0) { $comment = entity_create('comment', $values); $comment->save(); return $comment; - } + } } diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/CrudTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/CrudTest.php index b3559c3..e179458 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/CrudTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CrudTest.php @@ -55,9 +55,7 @@ function testBundleMapping() { // Test that the bundle mapping can be saved. $types = array('sioc:Post', 'foaf:Document'); rdf_get_mapping($this->entity_type, $this->bundle) - ->setBundleMapping(array( - 'types' => $types - )) + ->setBundleMapping(array('types' => $types)) ->save(); $bundle_mapping = rdf_get_mapping($this->entity_type, $this->bundle) ->getBundleMapping(); @@ -66,9 +64,7 @@ function testBundleMapping() { // Test that the bundle mapping can be edited. $types = array('schema:BlogPosting'); rdf_get_mapping($this->entity_type, $this->bundle) - ->setBundleMapping(array( - 'types' => $types - )) + ->setBundleMapping(array('types' => $types)) ->save(); $bundle_mapping = rdf_get_mapping($this->entity_type, $this->bundle) ->getBundleMapping(); @@ -107,6 +103,6 @@ function testFieldMapping() { $field_mapping = rdf_get_mapping($this->entity_type, $this->bundle) ->getFieldMapping($field_name); $intersection = array_intersect_key($field_mapping, $mapping); - $this->assertEqual($mapping, $intersection, 'Field mapping saved.'); + $this->assertEqual($mapping, $intersection, 'Field mapping updated.'); } } diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/FileFieldAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/FileFieldAttributesTest.php index 7b4b7a6..773b6c3 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/FileFieldAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/FileFieldAttributesTest.php @@ -35,21 +35,11 @@ public function setUp() { $this->fieldName = strtolower($this->randomName()); $type_name = 'article'; - $field_settings = array( - 'display_field' => '1', - 'display_default' => '1', - ); - $instance_settings = array( - 'description_field' => '1', - ); - $widget_settings = array(); - $this->createFileField($this->fieldName, $type_name, $field_settings, $instance_settings, $widget_settings); + $this->createFileField($this->fieldName, $type_name); // Set the teaser display to show this field. entity_get_display('node', 'article', 'teaser') - ->setComponent($this->fieldName, array( - 'type' => 'file_default', - )) + ->setComponent($this->fieldName, array('type' => 'file_default')) ->save(); // Set the RDF mapping for the new field. diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/ImageFieldAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/ImageFieldAttributesTest.php index 360e853..546fae5 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/ImageFieldAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/ImageFieldAttributesTest.php @@ -66,7 +66,7 @@ function testNodeTeaser() { // Set the display options for the teaser. $display_options = array( 'type' => 'image', - 'settings' => array('image_style'=> 'medium', 'image_link' => 'content'), + 'settings' => array('image_style' => 'medium', 'image_link' => 'content'), ); $display = entity_get_display('node', 'article', 'teaser'); $display->setComponent($this->fieldName, $display_options) diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/NodeAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/NodeAttributesTest.php index 6a0e267..bf18a63 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/NodeAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/NodeAttributesTest.php @@ -2,7 +2,7 @@ /** * @file - * Contains Drupal\rdf\Tests\NodeAttributesTest. + * Contains \Drupal\rdf\Tests\NodeAttributesTest. */ namespace Drupal\rdf\Tests; diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaAttributesTest.php index 9881e9c..7dc2345 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaAttributesTest.php @@ -2,7 +2,7 @@ /** * @file - * Contains Drupal\rdf\Tests\RdfaAttributesTest. + * Contains \Drupal\rdf\Tests\RdfaAttributesTest. */ namespace Drupal\rdf\Tests; @@ -35,12 +35,8 @@ public static function getInfo() { function testProperty() { $properties = array('dc:title'); - $mapping = array( - 'properties' => $properties, - ); - $expected_attributes = array( - 'property' => $properties, - ); + $mapping = array('properties' => $properties); + $expected_attributes = array('property' => $properties); $this->_testAttributes($expected_attributes, $mapping); } @@ -72,7 +68,7 @@ function testDatatypeCallback() { $datatype = 'xsd:dateTime'; $date = 1252750327; - $isoDate = date('c', $date); + $iso_date = date('c', $date); $mapping = array( 'datatype' => $datatype, @@ -82,7 +78,7 @@ function testDatatypeCallback() { $expected_attributes = array( 'datatype' => $datatype, 'property' => $properties, - 'content' => $isoDate, + 'content' => $iso_date, ); $this->_testAttributes($expected_attributes, $mapping, $date); @@ -98,9 +94,7 @@ function testRel() { 'properties' => $properties, 'mapping_type' => 'rel', ); - $expected_attributes = array( - 'rel' => $properties, - ); + $expected_attributes = array('rel' => $properties); $this->_testAttributes($expected_attributes, $mapping); } @@ -108,10 +102,12 @@ function testRel() { /** * Helper function to test attribute generation. * - * @param array $field_mapping - * The field mapping to merge into the RDF mapping config. * @param array $expected_attributes * The expected return of rdf_rdfa_attributes. + * @param array $field_mapping + * The field mapping to merge into the RDF mapping config. + * @param mixed $data + * The data to pass into the datatype callback, if specified. */ protected function _testAttributes($expected_attributes, $field_mapping, $data = NULL) { $this->saveMapping($field_mapping); diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/TaxonomyAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/TaxonomyAttributesTest.php index 435583c..99390d3 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/TaxonomyAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/TaxonomyAttributesTest.php @@ -2,7 +2,7 @@ /** * @file - * Contains Drupal\rdf\Tests\TaxonomyAttributesTest. + * Contains \Drupal\rdf\Tests\TaxonomyAttributesTest. */ namespace Drupal\rdf\Tests; @@ -36,11 +36,9 @@ function setUp() { // RDF mapping - term bundle. rdf_get_mapping('taxonomy_term', $this->vocabulary->id()) - ->setBundleMapping(array( - 'types' => array('skos:Concept') - )) + ->setBundleMapping(array('types' => array('skos:Concept'))) ->setFieldMapping('name', array( - 'properties' => array('rdfs:label', 'skos:prefLabel') + 'properties' => array('rdfs:label', 'skos:prefLabel'), )) ->save(); } diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/TaxonomyTermFieldAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/TaxonomyTermFieldAttributesTest.php index 75d23cc..0c7c0cb 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/TaxonomyTermFieldAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/TaxonomyTermFieldAttributesTest.php @@ -34,8 +34,8 @@ public static function getInfo() { public function setUp() { parent::setUp(); - $this->web_user = $this->drupalCreateUser(array('bypass node access', 'administer taxonomy')); - $this->drupalLogin($this->web_user); + $web_user = $this->drupalCreateUser(array('bypass node access', 'administer taxonomy')); + $this->drupalLogin($web_user); $this->vocabulary = $this->createVocabulary(); // Setup a field and instance. @@ -53,12 +53,8 @@ public function setUp() { ->save(); rdf_get_mapping('taxonomy_term', $this->vocabulary->id()) - ->setBundleMapping(array( - 'types' => array('skos:Concept') - )) - ->setFieldMapping('name', array( - 'properties' => array('rdfs:label'), - )) + ->setBundleMapping(array('types' => array('skos:Concept'))) + ->setFieldMapping('name', array('properties' => array('rdfs:label'))) ->save(); } @@ -71,9 +67,7 @@ public function setUp() { function testNodeTeaser() { // Set the teaser display to show this field. entity_get_display('node', 'article', 'teaser') - ->setComponent($this->fieldName, array( - 'type' => 'taxonomy_term_reference_link', - )) + ->setComponent($this->fieldName, array('type' => 'taxonomy_term_reference_link')) ->save(); // Create a term in each vocabulary. @@ -139,9 +133,9 @@ function testNodeTeaser() { /** * Create the taxonomy term reference field for testing. * - * @param $field_name + * @param string $field_name * The name of the field to create. - * @param $vocabulary + * @param \Drupal\taxonomy\Plugin\Core\Entity\Vocabulary $vocabulary * The vocabulary that the field should use. * * @todo Move this to TaxonomyTestBase, like the other field modules. @@ -158,7 +152,7 @@ protected function createTaxonomyTermReferenceField($field_name, $vocabulary) { 'parent' => '0', ), ), - ) + ), ); field_create_field($field); $instance = array( @@ -168,14 +162,10 @@ protected function createTaxonomyTermReferenceField($field_name, $vocabulary) { ); field_create_instance($instance); entity_get_form_display('node', 'article', 'default') - ->setComponent($field_name, array( - 'type' => 'options_select', - )) + ->setComponent($field_name, array('type' => 'options_select')) ->save(); entity_get_display('node', 'article', 'full') - ->setComponent($field_name, array( - 'type' => 'taxonomy_term_reference_link', - )) + ->setComponent($field_name, array('type' => 'taxonomy_term_reference_link')) ->save(); } } diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php index 7694925..d2d1cdd 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php @@ -2,7 +2,7 @@ /** * @file - * Contains Drupal\rdf\Tests\TrackerAttributesTest. + * Contains \Drupal\rdf\Tests\TrackerAttributesTest. */ namespace Drupal\rdf\Tests; diff --git a/core/modules/rdf/rdf.api.php b/core/modules/rdf/rdf.api.php index a1a7c18..4f30732 100644 --- a/core/modules/rdf/rdf.api.php +++ b/core/modules/rdf/rdf.api.php @@ -11,78 +11,6 @@ */ /** - * Allow modules to define RDF mappings for field bundles. - * - * Modules defining their own field bundles can specify which RDF semantics - * should be used to annotate these bundles. These mappings are then used for - * automatic RDFa output in the HTML code. - * - * @return - * A list of mapping structures, where each mapping is an associative array: - * - type: The name of an entity type (e.g., 'node', 'comment', and so on.) - * - bundle: The name of the bundle (e.g., 'page', 'article', or - * RDF_DEFAULT_BUNDLE for default mappings.) - * - mapping: The mapping structure which applies to the entity type and - * bundle. A mapping structure is an array with keys corresponding to - * existing field instances in the bundle. Each field is then described in - * terms of the RDF mapping: - * - predicates: An array of RDF predicates which describe the relation - * between the bundle (RDF subject) and the value of the field (RDF - * object). This value is either some text, another bundle, or a URI in - * general. - * - datatype: Is used along with 'callback' to format data so that it is - * readable by machines. A typical example is a date which can be written - * in many different formats but should be translated into a uniform - * format for machine consumption. - * - callback: A function name to invoke for 'datatype'. - * - type: A string used to determine the type of RDFa markup which will be - * used in the final HTML output, depending on whether the RDF object is a - * literal text or another RDF resource. - * - rdftype: A special property used to define the type of the instance. - * Its value should be an array of RDF classes. - * - * @ingroup rdf - */ -function hook_rdf_mapping() { - return array( - array( - 'type' => 'comment', - 'bundle' => RDF_DEFAULT_BUNDLE, - 'mapping' => array( - 'rdftype' => array('sioc:Post', 'sioct:Comment'), - 'title' => array( - 'predicates' => array('dc:title'), - ), - 'created' => array( - 'predicates' => array('dc:date', 'dc:created'), - 'datatype' => 'xsd:dateTime', - 'callback' => 'date_iso8601', - ), - 'changed' => array( - 'predicates' => array('dc:modified'), - 'datatype' => 'xsd:dateTime', - 'callback' => 'date_iso8601', - ), - 'comment_body' => array( - 'predicates' => array('content:encoded'), - ), - 'pid' => array( - 'predicates' => array('sioc:reply_of'), - 'mapping_type' => 'rel', - ), - 'uid' => array( - 'predicates' => array('sioc:has_creator'), - 'mapping_type' => 'rel', - ), - 'name' => array( - 'predicates' => array('foaf:name'), - ), - ), - ), - ); -} - -/** * Allow modules to define namespaces for RDF mappings. * * Many common namespace prefixes are defined in rdf_rdf_namespaces(). However, diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index ba41fbb..14f2364 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -36,34 +36,6 @@ function rdf_help($path, $arg) { * classes and properties. This module takes care of injecting these mappings * into variables available to theme functions and templates. All Drupal core * themes are coded to be RDFa compatible. - * - * Example mapping from node.module: - * @code - * array( - * 'type' => 'node', - * 'bundle' => RDF_DEFAULT_BUNDLE, - * 'mapping' => array( - * 'types' => array('sioc:Item', 'foaf:Document'), - * 'title' => array( - * 'properties' => array('dc:title'), - * ), - * 'created' => array( - * 'properties' => array('dc:date', 'dc:created'), - * 'datatype' => 'xsd:dateTime', - * 'datatype_callback' => 'date_iso8601', - * ), - * 'body' => array( - * 'properties' => array('content:encoded'), - * ), - * 'uid' => array( - * 'properties' => array('sioc:has_creator'), - * ), - * 'name' => array( - * 'properties' => array('foaf:name'), - * ), - * ), - * ); - * @endcode */ /** * Returns the RDF mapping object associated to a bundle. @@ -163,7 +135,7 @@ function rdf_get_namespaces() { * These include $attributes, $title_attributes, $content_attributes and the * field-specific $item_attributes variables. * - * @param $mapping + * @param array $mapping * An array containing a mandatory 'properties' key and optional 'datatype', * 'datatype_callback' and 'type' keys. For example: * @code @@ -174,11 +146,11 @@ function rdf_get_namespaces() { * ), * ); * @endcode - * @param $data + * @param mixed $data * (optional) A value that needs to be converted by the provided callback * function. * - * @return + * @return array * RDFa attributes suitable for Drupal\Core\Template\Attribute. * * @see theme_rdf_template_variable_wrapper() @@ -391,7 +363,7 @@ function rdf_preprocess_node(&$variables) { 'about' => $variables['node_url'], 'property' => $comment_count_mapping['properties'], 'content' => $variables['node']->comment_count, - 'datatype' => isset($comment_count_mapping['datatype']) ? $comment_count_mapping['datatype'] : NULL, + 'datatype' => $comment_count_mapping['datatype'], ), ); drupal_add_html_head($element, 'rdf_node_comment_count'); @@ -468,7 +440,7 @@ function rdf_preprocess_user(&$variables) { 'property' => $name_mapping['properties'], 'content' => $account->name, 'lang' => '', - ) + ), ); drupal_add_html_head($username_meta, 'rdf_user_username'); } @@ -603,14 +575,14 @@ function rdf_preprocess_taxonomy_term(&$variables) { $name_field_mapping = $mapping->getFieldMapping('name'); // Adds the RDF type of the term and the term name in a tag. $term_label_meta = array( - '#tag' => 'meta', - '#attributes' => array( - 'about' => url('taxonomy/term/' . $term->id()), - 'typeof' => $bundle_mapping['types'], - 'property' => $name_field_mapping['properties'], - 'content' => $term->label(), - ), - ); + '#tag' => 'meta', + '#attributes' => array( + 'about' => url('taxonomy/term/' . $term->id()), + 'typeof' => $bundle_mapping['types'], + 'property' => $name_field_mapping['properties'], + 'content' => $term->label(), + ), + ); drupal_add_html_head($term_label_meta, 'rdf_term_label'); }