diff options
Diffstat (limited to 'core/modules/node/node.tokens.inc')
-rw-r--r-- | core/modules/node/node.tokens.inc | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc index 81fa3f088e0..2fcf0ddfa8f 100644 --- a/core/modules/node/node.tokens.inc +++ b/core/modules/node/node.tokens.inc @@ -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); } } |