Update to drupal-org-drupal 8.0.0-rc2. For more information, see https://www.drupal.org/node/2598668

This commit is contained in:
Pantheon Automation 2015-10-21 21:44:50 -07:00 committed by Greg Anderson
parent f32e58e4b1
commit 8e18df8c36
3062 changed files with 15044 additions and 172506 deletions

View file

@ -5,7 +5,7 @@
(function ($) {
"use strict";
'use strict';
/**
*

View file

@ -1,6 +1,5 @@
<?php
use Drupal\Core\Entity\EntityInterface;
use Drupal\comment\CommentInterface;
use Drupal\Core\Url;

View file

@ -11,24 +11,17 @@
*/
use Drupal\comment\CommentInterface;
use Drupal\comment\Entity\Comment;
use Drupal\comment\CommentManagerInterface;
use Drupal\comment\Entity\CommentType;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Url;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\FieldConfigInterface;
use Drupal\field\FieldStorageConfigInterface;
use Drupal\file\FileInterface;
use Drupal\user\EntityOwnerInterface;
use Drupal\node\NodeInterface;
use Drupal\user\RoleInterface;

View file

@ -5,7 +5,7 @@
(function ($, Drupal, drupalSettings) {
"use strict";
'use strict';
/**
* Add 'by-viewer' class to comments written by the current user.

View file

@ -8,7 +8,7 @@
(function ($, Drupal, window) {
"use strict";
'use strict';
/**
* Renders "new" comment indicators wherever necessary.

View file

@ -8,7 +8,7 @@
(function ($, Drupal) {
"use strict";
'use strict';
/**
* Render "X new comments" links wherever necessary.

View file

@ -20,7 +20,18 @@ process:
0: comment_no_subject
bundle: node_type
'default_value/0/status': comment
'settings/default_mode': comment_default_mode
'settings/default_mode':
plugin: static_map
source: comment_default_mode
map:
# COMMENT_MODE_FLAT_COLLAPSED --> COMMENT_MODE_FLAT
1: 0
# COMMENT_MODE_FLAT_EXPANDED --> COMMENT_MODE_FLAT
2: 0
# COMMENT_MODE_THREADED_COLLAPSED --> COMMENT_MODE_THREADED
3: 1
# COMMENT_MODE_THREADED_EXPANDED --> COMMENT_MODE_THREADED
4: 1
'settings/per_page': comment_default_per_page
'settings/anonymous': comment_anonymous
'settings/form_location': comment_form_location

View file

@ -10,13 +10,11 @@ namespace Drupal\comment;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Entity\EntityConstraintViolationListInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -265,7 +263,7 @@ class CommentForm extends ContentEntityForm {
public function buildEntity(array $form, FormStateInterface $form_state) {
/** @var \Drupal\comment\CommentInterface $comment */
$comment = parent::buildEntity($form, $form_state);
if (!$form_state->isValueEmpty('date') && $form_state->getValue('date') instanceOf DrupalDateTime) {
if (!$form_state->isValueEmpty('date') && $form_state->getValue('date') instanceof DrupalDateTime) {
$comment->setCreatedTime($form_state->getValue('date')->getTimestamp());
}
else {

View file

@ -208,7 +208,7 @@ class CommentLinkBuilder implements CommentLinkBuilderInterface {
if ($new_comments > 0) {
$page_number = $this->entityManager
->getStorage('comment')
->getNewCommentPageNumber($entity->{$field_name}->comment_count, $new_comments, $entity);
->getNewCommentPageNumber($entity->{$field_name}->comment_count, $new_comments, $entity, $field_name);
$query = $page_number ? ['page' => $page_number] : NULL;
$value = [
'new_comment_count' => (int) $new_comments,

View file

@ -8,7 +8,6 @@
namespace Drupal\comment;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;

View file

@ -8,8 +8,6 @@
namespace Drupal\comment;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
/**
* Comment manager contains common functions to manage comment fields.

View file

@ -135,7 +135,7 @@ class CommentStorage extends SqlContentEntityStorage implements CommentStorageIn
/**
* {@inheritdoc}
*/
public function getNewCommentPageNumber($total_comments, $new_comments, FieldableEntityInterface $entity, $field_name = 'comment') {
public function getNewCommentPageNumber($total_comments, $new_comments, FieldableEntityInterface $entity, $field_name) {
$field = $entity->getFieldDefinition($field_name);
$comments_per_page = $field->getSetting('per_page');

View file

@ -54,7 +54,7 @@ interface CommentStorageInterface extends EntityStorageInterface {
* @return array|null
* The page number where first new comment appears. (First page returns 0.)
*/
public function getNewCommentPageNumber($total_comments, $new_comments, FieldableEntityInterface $entity, $field_name = 'comment');
public function getNewCommentPageNumber($total_comments, $new_comments, FieldableEntityInterface $entity, $field_name);
/**
* Gets the display ordinal or page number for a comment.

View file

@ -7,7 +7,6 @@
namespace Drupal\comment;
use Drupal\Core\Entity\ContentEntityTypeInterface;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityTypeInterface;

View file

@ -7,7 +7,6 @@
namespace Drupal\comment;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;

View file

@ -335,7 +335,7 @@ class CommentController extends ControllerBase {
$node = $this->entityManager->getStorage('node')->load($nid);
$new = $this->commentManager->getCountNewComments($node);
$page_number = $this->entityManager()->getStorage('comment')
->getNewCommentPageNumber($node->{$field_name}->comment_count, $new, $node);
->getNewCommentPageNumber($node->{$field_name}->comment_count, $new, $node, $field_name);
$query = $page_number ? array('page' => $page_number) : NULL;
$links[$nid] = array(
'new_comment_count' => (int) $new,

View file

@ -8,7 +8,6 @@
namespace Drupal\comment\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\comment\CommentTypeInterface;
/**

View file

@ -12,7 +12,6 @@ use Drupal\Core\Entity\EntityDeleteForm;
use Drupal\Core\Entity\EntityManager;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\field\Entity\FieldStorageConfig;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

View file

@ -7,12 +7,8 @@
namespace Drupal\comment\Plugin\Field\FieldFormatter;
use Drupal\comment\CommentManagerInterface;
use Drupal\comment\CommentStorageInterface;
use Drupal\comment\Entity\Comment;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityViewBuilderInterface;
use Drupal\Core\Entity\EntityFormBuilderInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;

View file

@ -161,12 +161,28 @@ class NodeNewComments extends NumericField {
*/
protected function renderLink($data, ResultRow $values) {
if (!empty($this->options['link_to_comment']) && $data !== NULL && $data !== '') {
$node_type = $this->getValue($values, 'type');
$node = entity_create('node', array(
'nid' => $this->getValue($values, 'nid'),
'type' => $this->getValue($values, 'type'),
'type' => $node_type,
));
$page_number = \Drupal::entityManager()->getStorage('comment')
->getNewCommentPageNumber($this->getValue($values, 'comment_count'), $this->getValue($values), $node);
// Because there is no support for selecting a specific comment field to
// reference, we arbitrarily use the first such field name we find.
// @todo Provide a means for selecting the comment field.
// https://www.drupal.org/node/2594201
$entity_manager = \Drupal::entityManager();
$field_map = $entity_manager->getFieldMapByFieldType('comment');
$comment_field_name = 'comment';
foreach ($field_map['node'] as $field_name => $field_data) {
foreach ($field_data['bundles'] as $bundle_name) {
if ($node_type == $bundle_name) {
$comment_field_name = $field_name;
break 2;
}
}
}
$page_number = $entity_manager->getStorage('comment')
->getNewCommentPageNumber($this->getValue($values, 'comment_count'), $this->getValue($values), $node, $comment_field_name);
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['url'] = $node->urlInfo();
$this->options['alter']['query'] = $page_number ? array('page' => $page_number) : NULL;

View file

@ -7,7 +7,6 @@
namespace Drupal\comment\Plugin\views\wizard;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\wizard\WizardPluginBase;
/**

View file

@ -8,7 +8,6 @@
namespace Drupal\comment\Tests;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Session\UserSession;
use Drupal\comment\CommentInterface;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
use Symfony\Component\HttpFoundation\Request;

View file

@ -243,7 +243,7 @@ class CommentFieldAccessTest extends EntityUnitTestBase {
foreach ($permutations as $set) {
$may_view = $set['comment']->{$field}->access('view', $set['user']);
$may_update = $set['comment']->{$field}->access('edit', $set['user']);
// Nobody has access to to view the hostname field.
// Nobody has access to view the hostname field.
if ($field === 'hostname') {
$view_access = FALSE;
$state = 'cannot';

View file

@ -94,6 +94,55 @@ class CommentFieldsTest extends CommentTestBase {
$this->assertEqual(1, count($elements), 'There is one comment field on the node.');
}
/**
* Tests link building with non-default comment field names.
*/
public function testCommentFieldLinksNonDefaultName() {
$this->drupalCreateContentType(['type' => 'test_node_type']);
$this->addDefaultCommentField('node', 'test_node_type', 'comment2');
$web_user2 = $this->drupalCreateUser([
'access comments',
'post comments',
'create article content',
'edit own comments',
'skip comment approval',
'access content',
]);
// Create a sample node.
$node = $this->drupalCreateNode([
'title' => 'Baloney',
'type' => 'test_node_type',
]);
// Go to the node first so that webuser2 see new comments.
$this->drupalLogin($web_user2);
$this->drupalGet($node->urlInfo());
$this->drupalLogout();
// Test that buildCommentedEntityLinks() does not break when the 'comment'
// field does not exist. Requires at least one comment.
$this->drupalLogin($this->webUser);
$this->postComment($node, 'Here is a comment', '', NULL, 'comment2');
$this->drupalLogout();
$this->drupalLogin($web_user2);
// We want to check the attached drupalSettings of
// \Drupal\comment\CommentLinkBuilder::buildCommentedEntityLinks. Therefore
// we need a node listing, let's use views for that.
$this->container->get('module_installer')->install(['views'], TRUE);
// We also need a router rebuild, as the router is lazily rebuild in the
// module installer.
\Drupal::service('router.builder')->rebuild();
$this->drupalGet('node');
$link_info = $this->getDrupalSettings()['comment']['newCommentsLinks']['node']['comment2']['2'];
$this->assertIdentical($link_info['new_comment_count'], 1);
$this->assertIdentical($link_info['first_new_comment_link'], $node->url('canonical', ['fragment' => 'new']));
}
/**
* Tests creating a comment field through the interface.
*/

View file

@ -435,7 +435,7 @@ class CommentNonNodeTest extends WebTestBase {
$data = array('bundle' => 'entity_test', 'name' => $random_label);
$new_entity = entity_create('entity_test', $data);
$new_entity->save();
$this->drupalGet('entity_test/manage/' . $new_entity->id());
$this->drupalGet('entity_test/manage/' . $new_entity->id() . '/edit');
$this->assertNoFieldChecked('edit-field-foobar-0-status-1');
$this->assertFieldChecked('edit-field-foobar-0-status-2');
$this->assertNoField('edit-field-foobar-0-status-0');

View file

@ -250,7 +250,7 @@ class CommentPagerTest extends CommentTestBase {
$node = Node::load($node->id());
foreach ($expected_pages as $new_replies => $expected_page) {
$returned_page = \Drupal::entityManager()->getStorage('comment')
->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node);
->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node, 'comment');
$this->assertIdentical($expected_page, $returned_page, format_string('Flat mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page)));
}
@ -269,7 +269,7 @@ class CommentPagerTest extends CommentTestBase {
$node = Node::load($node->id());
foreach ($expected_pages as $new_replies => $expected_page) {
$returned_page = \Drupal::entityManager()->getStorage('comment')
->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node);
->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node, 'comment');
$this->assertEqual($expected_page, $returned_page, format_string('Threaded mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page)));
}
}

View file

@ -10,7 +10,6 @@ namespace Drupal\comment\Tests;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Component\Utility\Xss;
use Drupal\comment\Entity\Comment;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\node\Entity\Node;

View file

@ -7,6 +7,7 @@
namespace Drupal\comment\Tests\Migrate\d6;
use Drupal\comment\CommentManagerInterface;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
use Drupal\node\Entity\Node;
@ -44,21 +45,21 @@ class MigrateCommentVariableInstanceTest extends MigrateDrupal6TestBase {
$this->assertIdentical(0, $node->comment->status);
$this->assertIdentical('comment', $node->comment->getFieldDefinition()->getName());
$settings = $node->comment->getFieldDefinition()->getSettings();
$this->assertIdentical(4, $settings['default_mode']);
$this->assertIdentical(CommentManagerInterface::COMMENT_MODE_THREADED, $settings['default_mode']);
$this->assertIdentical(50, $settings['per_page']);
$this->assertIdentical(0, $settings['anonymous']);
$this->assertIdentical(FALSE, $settings['form_location']);
$this->assertIdentical(1, $settings['preview']);
$this->assertFalse($settings['anonymous']);
$this->assertFalse($settings['form_location']);
$this->assertTrue($settings['preview']);
$node = Node::create(['type' => 'story']);
$this->assertIdentical(2, $node->comment_no_subject->status);
$this->assertIdentical('comment_no_subject', $node->comment_no_subject->getFieldDefinition()->getName());
$settings = $node->comment_no_subject->getFieldDefinition()->getSettings();
$this->assertIdentical(2, $settings['default_mode']);
$this->assertIdentical(CommentManagerInterface::COMMENT_MODE_FLAT, $settings['default_mode']);
$this->assertIdentical(70, $settings['per_page']);
$this->assertIdentical(1, $settings['anonymous']);
$this->assertIdentical(FALSE, $settings['form_location']);
$this->assertIdentical(0, $settings['preview']);
$this->assertTrue($settings['anonymous']);
$this->assertFalse($settings['form_location']);
$this->assertFalse($settings['preview']);
}
}

View file

@ -11,7 +11,6 @@ use Drupal\comment\CommentInterface;
use Drupal\comment\Entity\Comment;
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
use Drupal\node\NodeInterface;
use Drupal\user\Entity\User;
/**
* Tests migration of comments from Drupal 7.
@ -37,12 +36,6 @@ class MigrateCommentTest extends MigrateDrupal7TestBase {
'd7_user_role',
'd7_user',
]);
// The test database doesn't include uid 1, so we'll need to create it.
User::create(array(
'uid' => 1,
'name' => 'admin',
'mail' => 'admin@local.host',
))->save();
$this->executeMigration('d7_node_type');
// We only need the test_content_type node migration to run for real, so
// mock all the others.

View file

@ -6,8 +6,6 @@
* markup in edge case scenarios where comments have empty titles.
*/
use Drupal\comment\CommentInterface;
/**
* Implements hook_preprocess_comment().
*/

View file

@ -7,7 +7,6 @@
namespace Drupal\Tests\comment\Unit\Entity;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Entity\EntityType;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;