Update core 8.3.0

This commit is contained in:
Rob Davies 2017-04-13 15:53:35 +01:00
parent da7a7918f8
commit cd7a898e66
6144 changed files with 132297 additions and 87747 deletions

View file

@ -14,71 +14,71 @@ use Drupal\user\Entity\User;
* Implements hook_token_info().
*/
function node_token_info() {
$type = array(
$type = [
'name' => t('Nodes'),
'description' => t('Tokens related to individual content items, or "nodes".'),
'needs-data' => 'node',
);
];
// Core tokens for nodes.
$node['nid'] = array(
$node['nid'] = [
'name' => t("Content ID"),
'description' => t('The unique ID of the content item, or "node".'),
);
$node['vid'] = array(
];
$node['vid'] = [
'name' => t("Revision ID"),
'description' => t("The unique ID of the node's latest revision."),
);
$node['type'] = array(
];
$node['type'] = [
'name' => t("Content type"),
);
$node['type-name'] = array(
];
$node['type-name'] = [
'name' => t("Content type name"),
'description' => t("The human-readable name of the node type."),
);
$node['title'] = array(
];
$node['title'] = [
'name' => t("Title"),
);
$node['body'] = array(
];
$node['body'] = [
'name' => t("Body"),
'description' => t("The main body text of the node."),
);
$node['summary'] = array(
];
$node['summary'] = [
'name' => t("Summary"),
'description' => t("The summary of the node's main body text."),
);
$node['langcode'] = array(
];
$node['langcode'] = [
'name' => t('Language code'),
'description' => t('The language code of the language the node is written in.'),
);
$node['url'] = array(
];
$node['url'] = [
'name' => t("URL"),
'description' => t("The URL of the node."),
);
$node['edit-url'] = array(
];
$node['edit-url'] = [
'name' => t("Edit URL"),
'description' => t("The URL of the node's edit page."),
);
];
// Chained tokens for nodes.
$node['created'] = array(
$node['created'] = [
'name' => t("Date created"),
'type' => 'date',
);
$node['changed'] = array(
];
$node['changed'] = [
'name' => t("Date changed"),
'description' => t("The date the node was most recently updated."),
'type' => 'date',
);
$node['author'] = array(
];
$node['author'] = [
'name' => t("Author"),
'type' => 'user',
);
];
return array(
'types' => array('node' => $type),
'tokens' => array('node' => $node),
);
return [
'types' => ['node' => $type],
'tokens' => ['node' => $node],
];
}
/**
@ -87,7 +87,7 @@ function node_token_info() {
function node_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
$token_service = \Drupal::token();
$url_options = array('absolute' => TRUE);
$url_options = ['absolute' => TRUE];
if (isset($options['langcode'])) {
$url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']);
$langcode = $options['langcode'];
@ -95,7 +95,7 @@ function node_tokens($type, $tokens, array $data, array $options, BubbleableMeta
else {
$langcode = LanguageInterface::LANGCODE_DEFAULT;
}
$replacements = array();
$replacements = [];
if ($type == 'node' && !empty($data['node'])) {
/** @var \Drupal\node\NodeInterface $node */
@ -127,7 +127,7 @@ function node_tokens($type, $tokens, array $data, array $options, BubbleableMeta
case 'body':
case 'summary':
$translation = \Drupal::entityManager()->getTranslationFromContext($node, $langcode, array('operation' => 'node_tokens'));
$translation = \Drupal::entityManager()->getTranslationFromContext($node, $langcode, ['operation' => 'node_tokens']);
if ($translation->hasField('body') && ($items = $translation->get('body')) && !$items->isEmpty()) {
$item = $items[0];
// If the summary was requested and is not empty, use it.
@ -195,15 +195,15 @@ function node_tokens($type, $tokens, array $data, array $options, BubbleableMeta
}
if ($author_tokens = $token_service->findWithPrefix($tokens, 'author')) {
$replacements += $token_service->generate('user', $author_tokens, array('user' => $node->getOwner()), $options, $bubbleable_metadata);
$replacements += $token_service->generate('user', $author_tokens, ['user' => $node->getOwner()], $options, $bubbleable_metadata);
}
if ($created_tokens = $token_service->findWithPrefix($tokens, 'created')) {
$replacements += $token_service->generate('date', $created_tokens, array('date' => $node->getCreatedTime()), $options, $bubbleable_metadata);
$replacements += $token_service->generate('date', $created_tokens, ['date' => $node->getCreatedTime()], $options, $bubbleable_metadata);
}
if ($changed_tokens = $token_service->findWithPrefix($tokens, 'changed')) {
$replacements += $token_service->generate('date', $changed_tokens, array('date' => $node->getChangedTime()), $options, $bubbleable_metadata);
$replacements += $token_service->generate('date', $changed_tokens, ['date' => $node->getChangedTime()], $options, $bubbleable_metadata);
}
}