updated core and modules

This commit is contained in:
Bachir Soussi Chiadmi
2017-09-09 16:27:51 +02:00
parent 027aa99b32
commit 41863f872c
7810 changed files with 318922 additions and 83631 deletions
+17 -10
View File
@@ -12,10 +12,17 @@ use Drupal\rdf\RdfMappingInterface;
* @ConfigEntityType(
* id = "rdf_mapping",
* label = @Translation("RDF mapping"),
* label_singular = @Translation("RDF mapping item"),
* label_plural = @Translation("RDF mappings items"),
* label_count = @PluralTranslation(
* singular = "@count RDF mapping item",
* plural = "@count RDF mapping items",
* ),
* config_prefix = "mapping",
* entity_keys = {
* "id" = "id"
* },
* admin_permission = "administer site configuration",
* config_export = {
* "id",
* "targetEntityType",
@@ -53,20 +60,20 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
*
* @var array
*/
protected $types = array();
protected $types = [];
/**
* The mappings for fields on this bundle.
*
* @var array
*/
protected $fieldMappings = array();
protected $fieldMappings = [];
/**
* {@inheritdoc}
*/
public function getPreparedBundleMapping() {
return array('types' => $this->types);
return ['types' => $this->types];
}
/**
@@ -74,9 +81,9 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
*/
public function getBundleMapping() {
if (!empty($this->types)) {
return array('types' => $this->types);
return ['types' => $this->types];
}
return array();
return [];
}
/**
@@ -94,16 +101,16 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
* {@inheritdoc}
*/
public function getPreparedFieldMapping($field_name) {
$field_mapping = array(
$field_mapping = [
'properties' => NULL,
'datatype' => NULL,
'datatype_callback' => NULL,
'mapping_type' => NULL,
);
];
if (isset($this->fieldMappings[$field_name])) {
$field_mapping = array_merge($field_mapping, $this->fieldMappings[$field_name]);
}
return empty($field_mapping['properties']) ? array() : $field_mapping;
return empty($field_mapping['properties']) ? [] : $field_mapping;
}
/**
@@ -113,13 +120,13 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
if (isset($this->fieldMappings[$field_name])) {
return $this->fieldMappings[$field_name];
}
return array();
return [];
}
/**
* {@inheritdoc}
*/
public function setFieldMapping($field_name, array $mapping = array()) {
public function setFieldMapping($field_name, array $mapping = []) {
$this->fieldMappings[$field_name] = $mapping;
return $this;
}
+1 -1
View File
@@ -102,6 +102,6 @@ interface RdfMappingInterface extends ConfigEntityInterface {
* @return \Drupal\rdf\Entity\RdfMapping
* The RdfMapping object.
*/
public function setFieldMapping($field_name, array $mapping = array());
public function setFieldMapping($field_name, array $mapping = []);
}
@@ -22,7 +22,7 @@ class SchemaOrgDataConverter {
*
* @see http://schema.org/UserInteraction
*/
static function interactionCount($count, $arguments) {
public static function interactionCount($count, $arguments) {
$interaction_type = $arguments['interaction_type'];
return "$interaction_type:$count";
}
@@ -20,7 +20,7 @@ class CommentAttributesTest extends CommentTestBase {
*
* @var array
*/
public static $modules = array('views', 'node', 'comment', 'rdf');
public static $modules = ['views', 'node', 'comment', 'rdf'];
/**
* URI of the front page of the Drupal site.
@@ -40,11 +40,11 @@ class CommentAttributesTest extends CommentTestBase {
parent::setUp();
// Enables anonymous user comments.
user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array(
user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments' => TRUE,
'post comments' => TRUE,
'skip comment approval' => TRUE,
));
]);
// Allows anonymous to leave their contact information.
$this->setCommentAnonymous(COMMENT_ANONYMOUS_MAY_CONTACT);
$this->setCommentPreview(DRUPAL_OPTIONAL);
@@ -58,53 +58,53 @@ class CommentAttributesTest extends CommentTestBase {
// Set relation between node and comment.
$article_mapping = rdf_get_mapping('node', 'article');
$comment_count_mapping = array(
'properties' => array('sioc:num_replies'),
$comment_count_mapping = [
'properties' => ['sioc:num_replies'],
'datatype' => 'xsd:integer',
'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::rawValue'),
);
'datatype_callback' => ['callable' => 'Drupal\rdf\CommonDataConverter::rawValue'],
];
$article_mapping->setFieldMapping('comment_count', $comment_count_mapping)->save();
// Save user mapping.
$user_mapping = rdf_get_mapping('user', 'user');
$username_mapping = array(
'properties' => array('foaf:name'),
);
$username_mapping = [
'properties' => ['foaf:name'],
];
$user_mapping->setFieldMapping('name', $username_mapping)->save();
$user_mapping->setFieldMapping('homepage', array('properties' => array('foaf:page'), 'mapping_type' => 'rel'))->save();
$user_mapping->setFieldMapping('homepage', ['properties' => ['foaf:page'], 'mapping_type' => 'rel'])->save();
// Save comment mapping.
$mapping = rdf_get_mapping('comment', 'comment');
$mapping->setBundleMapping(array('types' => array('sioc:Post', 'sioct:Comment')))->save();
$field_mappings = array(
'subject' => array(
'properties' => array('dc:title'),
),
'created' => array(
'properties' => array('dc:date', 'dc:created'),
$mapping->setBundleMapping(['types' => ['sioc:Post', 'sioct:Comment']])->save();
$field_mappings = [
'subject' => [
'properties' => ['dc:title'],
],
'created' => [
'properties' => ['dc:date', 'dc:created'],
'datatype' => 'xsd:dateTime',
'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'),
),
'changed' => array(
'properties' => array('dc:modified'),
'datatype_callback' => ['callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'],
],
'changed' => [
'properties' => ['dc:modified'],
'datatype' => 'xsd:dateTime',
'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'),
),
'comment_body' => array(
'properties' => array('content:encoded'),
),
'pid' => array(
'properties' => array('sioc:reply_of'),
'datatype_callback' => ['callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'],
],
'comment_body' => [
'properties' => ['content:encoded'],
],
'pid' => [
'properties' => ['sioc:reply_of'],
'mapping_type' => 'rel',
),
'uid' => array(
'properties' => array('sioc:has_creator'),
],
'uid' => [
'properties' => ['sioc:has_creator'],
'mapping_type' => 'rel',
),
'name' => array(
'properties' => array('foaf:name'),
),
);
],
'name' => [
'properties' => ['foaf:name'],
],
];
// Iterate over shared field mappings and save.
foreach ($field_mappings as $field_name => $field_mapping) {
$mapping->setFieldMapping($field_name, $field_mapping)->save();
@@ -126,11 +126,11 @@ class CommentAttributesTest extends CommentTestBase {
$parser->parse($graph, $this->drupalGet('node'), 'rdfa', $this->baseUri);
// Number of comments.
$expected_value = array(
$expected_value = [
'type' => 'literal',
'value' => 2,
'datatype' => 'http://www.w3.org/2001/XMLSchema#integer',
);
];
$this->assertTrue($graph->hasProperty($this->nodeUri, 'http://rdfs.org/sioc/ns#num_replies', $expected_value), 'Number of comments found in RDF output of teaser view (sioc:num_replies).');
// Tests number of comments in full node view, expected value is the same.
@@ -183,7 +183,7 @@ class CommentAttributesTest extends CommentTestBase {
$this->_testBasicCommentRdfaMarkup($graph, $comment1);
// Posts comment #2 as anonymous user.
$anonymous_user = array();
$anonymous_user = [];
$anonymous_user['name'] = $this->randomMachineName();
$anonymous_user['mail'] = 'tester@simpletest.org';
$anonymous_user['homepage'] = 'http://example.org/';
@@ -222,22 +222,22 @@ class CommentAttributesTest extends CommentTestBase {
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->baseUri);
// Tests the reply_of relationship of a first level comment.
$expected_value = array(
$expected_value = [
'type' => 'uri',
'value' => $this->nodeUri,
);
];
$this->assertTrue($graph->hasProperty($comment_1_uri, 'http://rdfs.org/sioc/ns#reply_of', $expected_value), 'Comment relation to its node found in RDF output (sioc:reply_of).');
// Tests the reply_of relationship of a second level comment.
$expected_value = array(
$expected_value = [
'type' => 'uri',
'value' => $this->nodeUri,
);
];
$this->assertTrue($graph->hasProperty($comment_2_uri, 'http://rdfs.org/sioc/ns#reply_of', $expected_value), 'Comment relation to its node found in RDF output (sioc:reply_of).');
$expected_value = array(
$expected_value = [
'type' => 'uri',
'value' => $comment_1_uri,
);
];
$this->assertTrue($graph->hasProperty($comment_2_uri, 'http://rdfs.org/sioc/ns#reply_of', $expected_value), 'Comment relation to its parent comment found in RDF output (sioc:reply_of).');
}
@@ -251,61 +251,61 @@ class CommentAttributesTest extends CommentTestBase {
* @param $account
* An array containing information about an anonymous user.
*/
function _testBasicCommentRdfaMarkup($graph, CommentInterface $comment, $account = array()) {
$comment_uri = $comment->url('canonical', array('absolute' => TRUE));
public function _testBasicCommentRdfaMarkup($graph, CommentInterface $comment, $account = []) {
$comment_uri = $comment->url('canonical', ['absolute' => TRUE]);
// Comment type.
$expected_value = array(
$expected_value = [
'type' => 'uri',
'value' => 'http://rdfs.org/sioc/types#Comment',
);
];
$this->assertTrue($graph->hasProperty($comment_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Comment type found in RDF output (sioct:Comment).');
// Comment type.
$expected_value = array(
$expected_value = [
'type' => 'uri',
'value' => 'http://rdfs.org/sioc/ns#Post',
);
];
$this->assertTrue($graph->hasProperty($comment_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Comment type found in RDF output (sioc:Post).');
// Comment title.
$expected_value = array(
$expected_value = [
'type' => 'literal',
'value' => $comment->getSubject(),
'lang' => 'en',
);
];
$this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/dc/terms/title', $expected_value), 'Comment subject found in RDF output (dc:title).');
// Comment date.
$expected_value = array(
$expected_value = [
'type' => 'literal',
'value' => format_date($comment->getCreatedTime(), 'custom', 'c', 'UTC'),
'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime',
);
];
$this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/dc/terms/date', $expected_value), 'Comment date found in RDF output (dc:date).');
// Comment date.
$expected_value = array(
$expected_value = [
'type' => 'literal',
'value' => format_date($comment->getCreatedTime(), 'custom', 'c', 'UTC'),
'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime',
);
];
$this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/dc/terms/created', $expected_value), 'Comment date found in RDF output (dc:created).');
// Comment body.
$expected_value = array(
$expected_value = [
'type' => 'literal',
'value' => $comment->comment_body->value . "\n",
'lang' => 'en',
);
];
$this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/rss/1.0/modules/content/encoded', $expected_value), 'Comment body found in RDF output (content:encoded).');
// The comment author can be a registered user or an anonymous user.
if ($comment->getOwnerId() > 0) {
$author_uri = \Drupal::url('entity.user.canonical', ['user' => $comment->getOwnerId()], array('absolute' => TRUE));
$author_uri = \Drupal::url('entity.user.canonical', ['user' => $comment->getOwnerId()], ['absolute' => TRUE]);
// Comment relation to author.
$expected_value = array(
$expected_value = [
'type' => 'uri',
'value' => $author_uri,
);
];
$this->assertTrue($graph->hasProperty($comment_uri, 'http://rdfs.org/sioc/ns#has_creator', $expected_value), 'Comment relation to author found in RDF output (sioc:has_creator).');
}
else {
@@ -321,18 +321,18 @@ class CommentAttributesTest extends CommentTestBase {
// Author name.
$name = empty($account["name"]) ? $this->webUser->getUsername() : $account["name"] . " (not verified)";
$expected_value = array(
$expected_value = [
'type' => 'literal',
'value' => $name,
);
];
$this->assertTrue($graph->hasProperty($author_uri, 'http://xmlns.com/foaf/0.1/name', $expected_value), 'Comment author name found in RDF output (foaf:name).');
// Comment author homepage (only for anonymous authors).
if ($comment->getOwnerId() == 0) {
$expected_value = array(
$expected_value = [
'type' => 'uri',
'value' => 'http://example.org/',
);
];
$this->assertTrue($graph->hasProperty($author_uri, 'http://xmlns.com/foaf/0.1/page', $expected_value), 'Comment author link found in RDF output (foaf:page).');
}
}
@@ -353,8 +353,8 @@ class CommentAttributesTest extends CommentTestBase {
* @return \Drupal\comment\Entity\Comment
* The saved comment.
*/
function saveComment($nid, $uid, $contact = NULL, $pid = 0) {
$values = array(
public function saveComment($nid, $uid, $contact = NULL, $pid = 0) {
$values = [
'entity_id' => $nid,
'entity_type' => 'node',
'field_name' => 'comment',
@@ -363,7 +363,7 @@ class CommentAttributesTest extends CommentTestBase {
'subject' => $this->randomMachineName(),
'comment_body' => $this->randomMachineName(),
'status' => 1,
);
];
if ($contact) {
$values += $contact;
}
@@ -16,7 +16,7 @@ class TestDataConverter {
* @return string
* Returns the data.
*/
static function convertFoo($data) {
public static function convertFoo($data) {
return 'foo' . $data['value'];
}
@@ -17,33 +17,33 @@ class GetNamespacesTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('rdf', 'rdf_test_namespaces');
public static $modules = ['rdf', 'rdf_test_namespaces'];
/**
* Tests RDF namespaces.
*/
function testGetRdfNamespaces() {
public function testGetRdfNamespaces() {
// Fetches the front page and extracts RDFa 1.1 prefixes.
$this->drupalGet('');
$element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', array(
$element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
':prefix_binding' => 'rdfs: http://www.w3.org/2000/01/rdf-schema#',
));
]);
$this->assertTrue(!empty($element), 'A prefix declared once is displayed.');
$element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', array(
$element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
':prefix_binding' => 'foaf: http://xmlns.com/foaf/0.1/',
));
]);
$this->assertTrue(!empty($element), 'The same prefix declared in several implementations of hook_rdf_namespaces() is valid as long as all the namespaces are the same.');
$element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', array(
$element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
':prefix_binding' => 'foaf1: http://xmlns.com/foaf/0.1/',
));
]);
$this->assertTrue(!empty($element), 'Two prefixes can be assigned the same namespace.');
$element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', array(
$element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
':prefix_binding' => 'dc: http://purl.org/dc/terms/',
));
]);
$this->assertTrue(!empty($element), 'When a prefix has conflicting namespaces, the first declared one is used.');
}
@@ -19,7 +19,7 @@ class ImageFieldAttributesTest extends ImageFieldTestBase {
*
* @var array
*/
public static $modules = array('rdf', 'image');
public static $modules = ['rdf', 'image'];
/**
* The name of the image field used in the test.
@@ -52,11 +52,11 @@ class ImageFieldAttributesTest extends ImageFieldTestBase {
// Set the RDF mapping for the new field.
rdf_get_mapping('node', 'article')
->setFieldMapping($this->fieldName, array(
'properties' => array('og:image'),
->setFieldMapping($this->fieldName, [
'properties' => ['og:image'],
'mapping_type' => 'rel',
))
->setBundleMapping(array('types' => array()))
])
->setBundleMapping(['types' => []])
->save();
// Get the test image that simpletest provides.
@@ -71,12 +71,12 @@ class ImageFieldAttributesTest extends ImageFieldTestBase {
/**
* Tests that image fields in teasers have correct resources.
*/
function testNodeTeaser() {
public function testNodeTeaser() {
// Set the display options for the teaser.
$display_options = array(
$display_options = [
'type' => 'image',
'settings' => array('image_style' => 'medium', 'image_link' => 'content'),
);
'settings' => ['image_style' => 'medium', 'image_link' => 'content'],
];
$display = entity_get_display('node', 'article', 'teaser');
$display->setComponent($this->fieldName, $display_options)
->save();
@@ -96,17 +96,17 @@ class ImageFieldAttributesTest extends ImageFieldTestBase {
$image_uri = ImageStyle::load('medium')->buildUrl($this->file->getFileUri());
// Test relations from node to image.
$expected_value = array(
$expected_value = [
'type' => 'uri',
'value' => $image_uri,
);
];
$this->assertTrue($graph->hasProperty($node_uri, 'http://ogp.me/ns#image', $expected_value), 'Node to file relation found in RDF output (og:image).');
// Test image type.
$expected_value = array(
$expected_value = [
'type' => 'uri',
'value' => 'http://xmlns.com/foaf/0.1/Image',
);
];
$this->assertTrue($graph->hasProperty($image_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Image type found in RDF output (foaf:Image).');
}