Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0

This commit is contained in:
Pantheon Automation 2016-10-06 15:16:20 -07:00 committed by Greg Anderson
parent 2f563ab520
commit f1c8716f57
1732 changed files with 52334 additions and 11780 deletions

View file

@ -7,6 +7,8 @@
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Datetime\Entity\DateFormat;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Render\BubbleableMetadata;
/**
@ -19,15 +21,28 @@ function comment_token_info() {
'needs-data' => 'comment',
);
// @todo Make this work per field. See https://www.drupal.org/node/2031903.
$entity['comment-count'] = array(
'name' => t("Comment count"),
'description' => t("The number of comments posted on an entity."),
);
$entity['comment-count-new'] = array(
'name' => t("New comment count"),
'description' => t("The number of comments posted on an entity since the reader last viewed it."),
);
$tokens = [];
// Provide a integration for each entity type except comment.
foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type_id == 'comment' || !$entity_type->isSubclassOf(ContentEntityInterface::class)) {
continue;
}
if (\Drupal::service('comment.manager')->getFields($entity_type_id)) {
// Get the correct token type.
$token_type = ($entity_type_id == 'taxonomy_term') ? 'term' : $entity_type_id;
// @todo Make this work per field. See https://www.drupal.org/node/2031903.
$tokens[$token_type]['comment-count'] = [
'name' => t("Comment count"),
'description' => t("The number of comments posted on an entity."),
];
$tokens[$token_type]['comment-count-new'] = [
'name' => t("New comment count"),
'description' => t("The number of comments posted on an entity since the reader last viewed it."),
];
}
}
// Core comment tokens
$comment['cid'] = array(
@ -97,9 +112,8 @@ function comment_token_info() {
return array(
'types' => array('comment' => $type),
'tokens' => array(
'entity' => $entity,
'comment' => $comment,
),
) + $tokens,
);
}
@ -235,9 +249,10 @@ function comment_tokens($type, $tokens, array $data, array $options, BubbleableM
$replacements += $token_service->generate('user', $author_tokens, array('user' => $account), $options, $bubbleable_metadata);
}
}
elseif ($type == 'entity' & !empty($data['entity'])) {
// Replacement tokens for any content entities that have comment field.
elseif (!empty($data[$type]) && $data[$type] instanceof FieldableEntityInterface) {
/** @var $entity \Drupal\Core\Entity\FieldableEntityInterface */
$entity = $data['entity'];
$entity = $data[$type];
foreach ($tokens as $name => $original) {
switch ($name) {