diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-10-20 19:54:15 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-10-20 19:54:15 +0000 |
commit | 6551d1e2d5629317968cfa2a921dfdc2dfbdd446 (patch) | |
tree | b90243b6fa45192bc20b3249ab5d8207ecd73f2d | |
parent | ee7bd3ceab7f46a99c0e4390ec06669d405d1c1a (diff) | |
download | brdo-6551d1e2d5629317968cfa2a921dfdc2dfbdd446.tar.gz brdo-6551d1e2d5629317968cfa2a921dfdc2dfbdd446.tar.bz2 |
#493030 follow-up by sun: More RDF clean-ups.
-rw-r--r-- | modules/rdf/rdf.module | 16 | ||||
-rw-r--r-- | modules/rdf/rdf.test | 16 |
2 files changed, 16 insertions, 16 deletions
diff --git a/modules/rdf/rdf.module b/modules/rdf/rdf.module index 62b1a8c84..5d726727e 100644 --- a/modules/rdf/rdf.module +++ b/modules/rdf/rdf.module @@ -58,7 +58,7 @@ define('RDF_DEFAULT_BUNDLE', ''); /** - * Returns the mapping for the attributes of the given type, bundle pair. + * Returns the mapping for attributes of a given type/bundle pair. * * @param $type * An entity type. @@ -69,7 +69,7 @@ define('RDF_DEFAULT_BUNDLE', ''); * The mapping corresponding to the requested type/bundle pair or an empty * array. */ -function rdf_get_mapping($type, $bundle = RDF_DEFAULT_BUNDLE) { +function rdf_mapping_load($type, $bundle = RDF_DEFAULT_BUNDLE) { // Retrieve the mapping from the entity info. $entity_info = entity_get_info($type); if (!empty($entity_info['bundles'][$bundle]['rdf_mapping'])) { @@ -111,7 +111,7 @@ function _rdf_get_default_mapping($type) { } /** - * Reads an RDF mapping record directly from the database. + * Helper function to retrieve a RDF mapping from the database. * * @param $type * The entity type the mapping refers to. @@ -119,9 +119,9 @@ function _rdf_get_default_mapping($type) { * The bundle the mapping refers to. * * @return - * An RDF mapping structure or FALSE if the mapping could not be found. + * A RDF mapping structure or FALSE if no record was found. */ -function rdf_mapping_load($type, $bundle) { +function _rdf_mapping_load($type, $bundle) { $mapping = db_select('rdf_mapping') ->fields(NULL, array('mapping')) ->condition('type', $type) @@ -291,7 +291,7 @@ function rdf_entity_info_alter(&$entity_info) { foreach ($entity_info as $entity_type => $entity_type_info) { if (isset($entity_type_info['bundles'])) { foreach ($entity_type_info['bundles'] as $bundle => $bundle_info) { - if ($mapping = rdf_mapping_load($entity_type, $bundle)) { + if ($mapping = _rdf_mapping_load($entity_type, $bundle)) { $entity_info[$entity_type]['bundles'][$bundle]['rdf_mapping'] = $mapping; } else { @@ -311,7 +311,7 @@ function rdf_entity_load($entities, $type) { foreach ($entities as $entity) { // Extracts the bundle of the entity being loaded. list($id, $vid, $bundle) = field_extract_ids($type, $entity); - $entity->rdf_mapping = rdf_get_mapping($type, $bundle); + $entity->rdf_mapping = rdf_mapping_load($type, $bundle); } } @@ -403,7 +403,7 @@ function rdf_preprocess_node(&$variables) { function rdf_preprocess_field(&$variables) { $entity_type = $variables['element']['#object_type']; $instance = $variables['instance']; - $mapping = rdf_get_mapping($entity_type, $instance['bundle']); + $mapping = rdf_mapping_load($entity_type, $instance['bundle']); $field_name = $instance['field_name']; if (!empty($mapping) && !empty($mapping[$field_name])) { diff --git a/modules/rdf/rdf.test b/modules/rdf/rdf.test index 978b6c582..3055a4cd5 100644 --- a/modules/rdf/rdf.test +++ b/modules/rdf/rdf.test @@ -27,7 +27,7 @@ class RdfMappingHookTestCase extends DrupalWebTestCase { */ function testMapping() { // Test that the mapping is returned correctly by the hook. - $mapping = rdf_get_mapping('test_entity', 'test_bundle'); + $mapping = rdf_mapping_load('test_entity', 'test_bundle'); $this->assertIdentical($mapping['rdftype'], array('sioc:Post'), t('Mapping for rdftype is sioc:Post.')); $this->assertIdentical($mapping['title'], array('predicates' => array('dc:title')), t('Mapping for title is dc:title.')); $this->assertIdentical($mapping['created'], array( @@ -37,7 +37,7 @@ class RdfMappingHookTestCase extends DrupalWebTestCase { ), t('Mapping for created is dc:created with datatype xsd:dateTime and callback date_iso8601.')); $this->assertIdentical($mapping['uid'], array('predicates' => array('sioc:has_creator', 'dc:creator')), t('Mapping for uid is sioc:has_creator and dc:creator.')); - $mapping = rdf_get_mapping('test_entity', 'test_bundle_no_mapping'); + $mapping = rdf_mapping_load('test_entity', 'test_bundle_no_mapping'); $this->assertEqual($mapping, array(), t('Empty array returned when an entity type, bundle pair has no mapping.')); } } @@ -67,7 +67,7 @@ class RdfMarkupTestCase extends DrupalWebTestCase { $expected_property = array('dc:created'); $expected_value = $isoDate; - $mapping = rdf_get_mapping('test_entity', 'test_bundle'); + $mapping = rdf_mapping_load('test_entity', 'test_bundle'); $attributes = rdf_rdfa_attributes($mapping['created'], $date); $this->assertEqual($expected_type, $attributes['datatype']); @@ -97,28 +97,28 @@ class RdfCrudTestCase extends DrupalWebTestCase { $test_mapping = rdf_test_rdf_mapping(); // Verify loading of a default mapping. - $this->assertFalse(count(rdf_mapping_load('test_entity', 'test_bundle')), t('Default mapping was found.')); + $this->assertFalse(count(_rdf_mapping_load('test_entity', 'test_bundle')), t('Default mapping was found.')); // Verify saving a mapping. $mapping = (array) $test_mapping; rdf_mapping_save($mapping[0]); $this->assertEqual($mapping[0]['mapping'], $test_mapping[0]['mapping'], t('Saved mapping equals default mapping.')); $this->assertTrue(rdf_mapping_save($mapping[1]) === SAVED_NEW, t('Second mapping was inserted.')); - $this->assertEqual($mapping[1]['mapping'], rdf_mapping_load($test_mapping[1]['type'], $test_mapping[1]['bundle']), t('Second mapping equals default mapping.')); + $this->assertEqual($mapping[1]['mapping'], _rdf_mapping_load($test_mapping[1]['type'], $test_mapping[1]['bundle']), t('Second mapping equals default mapping.')); // Verify loading of saved mapping. - $this->assertEqual($mapping[0]['mapping'], rdf_mapping_load($test_mapping[0]['type'], $test_mapping[0]['bundle']), t('Saved mapping equals loaded default mapping.')); + $this->assertEqual($mapping[0]['mapping'], _rdf_mapping_load($test_mapping[0]['type'], $test_mapping[0]['bundle']), t('Saved mapping equals loaded default mapping.')); // Verify updating of mapping. $mapping[0]['mapping']['boofar'] = array( 'predicates' => array('foo:bar'), ); $this->assertTrue(rdf_mapping_save($mapping[0]) === SAVED_UPDATED, t('Mapping was updated.')); - $this->assertEqual($mapping[0]['mapping'], rdf_mapping_load($test_mapping[0]['type'], $test_mapping[0]['bundle']), t('Updated and loaded mapping are equal.')); + $this->assertEqual($mapping[0]['mapping'], _rdf_mapping_load($test_mapping[0]['type'], $test_mapping[0]['bundle']), t('Updated and loaded mapping are equal.')); // Verify deleting of mapping. $this->assertTrue(rdf_mapping_delete($test_mapping[0]['type'], $test_mapping[0]['bundle']), t('Mapping was deleted.')); - $this->assertFalse(rdf_mapping_load($test_mapping[0]['type'], $test_mapping[0]['bundle']), t('Deleted mapping is no longer found.')); + $this->assertFalse(_rdf_mapping_load($test_mapping[0]['type'], $test_mapping[0]['bundle']), t('Deleted mapping is no longer found.')); } } |