Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
|
@ -22,7 +22,7 @@ class ContactFormAccessControlHandler extends EntityAccessControlHandler {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
|
||||
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
|
||||
if ($operation == 'view') {
|
||||
// Do not allow access personal form via site-wide route.
|
||||
return AccessResult::allowedIf($account->hasPermission('access site-wide contact form') && $entity->id() !== 'personal')->cachePerPermissions();
|
||||
|
|
@ -33,7 +33,7 @@ class ContactFormAccessControlHandler extends EntityAccessControlHandler {
|
|||
return AccessResult::allowedIf($account->hasPermission('administer contact forms') && $entity->id() !== 'personal')->cachePerPermissions();
|
||||
}
|
||||
|
||||
return parent::checkAccess($entity, $operation, $langcode, $account);
|
||||
return parent::checkAccess($entity, $operation, $account);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface;
|
|||
interface ContactFormInterface extends ConfigEntityInterface {
|
||||
|
||||
/**
|
||||
* Returns list of recipient e-mail addresses.
|
||||
* Returns list of recipient email addresses.
|
||||
*
|
||||
* @return array
|
||||
* List of recipient e-mail addresses.
|
||||
* List of recipient email addresses.
|
||||
*/
|
||||
public function getRecipients();
|
||||
|
||||
|
|
@ -39,10 +39,10 @@ interface ContactFormInterface extends ConfigEntityInterface {
|
|||
public function getWeight();
|
||||
|
||||
/**
|
||||
* Sets list of recipient e-mail addresses.
|
||||
* Sets list of recipient email addresses.
|
||||
*
|
||||
* @param array $recipients
|
||||
* The desired list of e-mail addresses of this category.
|
||||
* The desired list of email addresses of this category.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -69,8 +69,8 @@ class ContactController extends ControllerBase {
|
|||
// If there are no forms, do not display the form.
|
||||
if (empty($contact_form)) {
|
||||
if ($this->currentUser()->hasPermission('administer contact forms')) {
|
||||
drupal_set_message($this->t('The contact form has not been configured. <a href="@add">Add one or more forms</a> .', array(
|
||||
'@add' => $this->url('contact.form_add'))), 'error');
|
||||
drupal_set_message($this->t('The contact form has not been configured. <a href=":add">Add one or more forms</a> .', array(
|
||||
':add' => $this->url('contact.form_add'))), 'error');
|
||||
return array();
|
||||
}
|
||||
else {
|
||||
|
|
@ -103,10 +103,10 @@ class ContactController extends ControllerBase {
|
|||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
* Exception is thrown when user tries to access a contact form for a
|
||||
* user who does not have an e-mail address configured.
|
||||
* user who does not have an email address configured.
|
||||
*/
|
||||
public function contactPersonalPage(UserInterface $user) {
|
||||
// Do not continue if the user does not have an e-mail address configured.
|
||||
// Do not continue if the user does not have an email address configured.
|
||||
if (!$user->getEmail()) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
|
@ -117,7 +117,7 @@ class ContactController extends ControllerBase {
|
|||
));
|
||||
|
||||
$form = $this->entityFormBuilder()->getForm($message);
|
||||
$form['#title'] = $this->t('Contact @username', array('@username' => $user->getUsername()));
|
||||
$form['#title'] = $this->t('Contact @username', array('@username' => $user->getDisplayName()));
|
||||
$form['#cache']['contexts'][] = 'user.permissions';
|
||||
return $form;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class MailHandler implements MailHandlerInterface {
|
|||
|
||||
// For the email message, clarify that the sender name is not verified; it
|
||||
// could potentially clash with a username on this site.
|
||||
$sender_cloned->name = $this->t('!name (not verified)', array('!name' => $message->getSenderName()));
|
||||
$sender_cloned->name = $this->t('@name (not verified)', array('@name' => $message->getSenderName()));
|
||||
}
|
||||
|
||||
// Build email parameters.
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
namespace Drupal\contact;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Datetime\DateFormatter;
|
||||
use Drupal\Core\Datetime\DateFormatterInterface;
|
||||
use Drupal\Core\Entity\ContentEntityForm;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Flood\FloodInterface;
|
||||
|
|
@ -53,7 +53,7 @@ class MessageForm extends ContentEntityForm {
|
|||
/**
|
||||
* The date formatter service.
|
||||
*
|
||||
* @var \Drupal\Core\Datetime\DateFormatter
|
||||
* @var \Drupal\Core\Datetime\DateFormatterInterface
|
||||
*/
|
||||
protected $dateFormatter;
|
||||
|
||||
|
|
@ -68,10 +68,10 @@ class MessageForm extends ContentEntityForm {
|
|||
* The language manager service.
|
||||
* @param \Drupal\contact\MailHandlerInterface $mail_handler
|
||||
* The contact mail handler service.
|
||||
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
|
||||
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
|
||||
* The date service.
|
||||
*/
|
||||
public function __construct(EntityManagerInterface $entity_manager, FloodInterface $flood, LanguageManagerInterface $language_manager, MailHandlerInterface $mail_handler, DateFormatter $date_formatter) {
|
||||
public function __construct(EntityManagerInterface $entity_manager, FloodInterface $flood, LanguageManagerInterface $language_manager, MailHandlerInterface $mail_handler, DateFormatterInterface $date_formatter) {
|
||||
parent::__construct($entity_manager);
|
||||
$this->flood = $flood;
|
||||
$this->languageManager = $language_manager;
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ class MessageViewBuilder extends EntityViewBuilder {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) {
|
||||
$build = parent::getBuildDefaults($entity, $view_mode, $langcode);
|
||||
protected function getBuildDefaults(EntityInterface $entity, $view_mode) {
|
||||
$build = parent::getBuildDefaults($entity, $view_mode);
|
||||
// The message fields are individually rendered into email templates, so
|
||||
// the entity has no template itself.
|
||||
unset($build['#theme']);
|
||||
|
|
@ -31,8 +31,8 @@ class MessageViewBuilder extends EntityViewBuilder {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildComponents(array &$build, array $entities, array $displays, $view_mode, $langcode = NULL) {
|
||||
parent::buildComponents($build, $entities, $displays, $view_mode, $langcode);
|
||||
public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
|
||||
parent::buildComponents($build, $entities, $displays, $view_mode);
|
||||
|
||||
foreach ($entities as $id => $entity) {
|
||||
// Add the message extra field, if enabled.
|
||||
|
|
|
|||
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\contact\Plugin\migrate\source\d6\ContactCategory.
|
||||
* Contains \Drupal\contact\Plugin\migrate\source\ContactCategory.
|
||||
*/
|
||||
|
||||
namespace Drupal\contact\Plugin\migrate\source\d6;
|
||||
namespace Drupal\contact\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 contact category source from database.
|
||||
* Contact category source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_contact_category",
|
||||
* id = "contact_category",
|
||||
* source_provider = "contact"
|
||||
* )
|
||||
*/
|
||||
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\contact\Plugin\migrate\source\d6\ContactSettings.
|
||||
* Contains \Drupal\contact\Plugin\migrate\source\ContactSettings.
|
||||
*/
|
||||
|
||||
namespace Drupal\contact\Plugin\migrate\source\d6;
|
||||
namespace Drupal\contact\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\Variable;
|
||||
|
||||
/**
|
||||
* @MigrateSource(
|
||||
* id = "d6_contact_settings",
|
||||
* id = "contact_settings",
|
||||
* source_provider = "contact"
|
||||
* )
|
||||
*/
|
||||
|
|
@ -20,13 +20,13 @@ class ContactSettings extends Variable {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function initializeIterator() {
|
||||
protected function initializeIterator() {
|
||||
$default_category = $this->select('contact', 'c')
|
||||
->fields('c', array('cid'))
|
||||
->fields('c', ['cid'])
|
||||
->condition('selected', 1)
|
||||
->execute()
|
||||
->fetchField();
|
||||
return new \ArrayIterator(array($this->values() + array('default_category' => $default_category)));
|
||||
return new \ArrayIterator([$this->values() + ['default_category' => $default_category]]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
namespace Drupal\contact\Tests;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\PlainTextOutput;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\user\RoleInterface;
|
||||
|
|
@ -79,12 +80,13 @@ class ContactPersonalTest extends WebTestBase {
|
|||
$this->assertEqual($mail['reply-to'], $this->webUser->getEmail());
|
||||
$this->assertEqual($mail['key'], 'user_mail');
|
||||
$variables = array(
|
||||
'!site-name' => $this->config('system.site')->get('name'),
|
||||
'!subject' => $message['subject[0][value]'],
|
||||
'!recipient-name' => $this->contactUser->getUsername(),
|
||||
'@site-name' => $this->config('system.site')->get('name'),
|
||||
'@subject' => $message['subject[0][value]'],
|
||||
'@recipient-name' => $this->contactUser->getUsername(),
|
||||
);
|
||||
$this->assertEqual($mail['subject'], t('[!site-name] !subject', $variables), 'Subject is in sent message.');
|
||||
$this->assertTrue(strpos($mail['body'], 'Hello ' . $variables['!recipient-name']) !== FALSE, 'Recipient name is in sent message.');
|
||||
$subject = PlainTextOutput::renderFromHtml(t('[@site-name] @subject', $variables));
|
||||
$this->assertEqual($mail['subject'], $subject, 'Subject is in sent message.');
|
||||
$this->assertTrue(strpos($mail['body'], 'Hello ' . $variables['@recipient-name']) !== FALSE, 'Recipient name is in sent message.');
|
||||
$this->assertTrue(strpos($mail['body'], $this->webUser->getUsername()) !== FALSE, 'Sender name is in sent message.');
|
||||
$this->assertTrue(strpos($mail['body'], $message['message[0][value]']) !== FALSE, 'Message body is in sent message.');
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ class ContactSitewideTest extends WebTestBase {
|
|||
parent::setUp();
|
||||
$this->drupalPlaceBlock('system_breadcrumb_block');
|
||||
$this->drupalPlaceBlock('local_actions_block');
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -129,7 +130,7 @@ class ContactSitewideTest extends WebTestBase {
|
|||
$max_length = EntityTypeInterface::BUNDLE_MAX_LENGTH;
|
||||
$max_length_exceeded = $max_length + 1;
|
||||
$this->addContactForm($id = Unicode::strtolower($this->randomMachineName($max_length_exceeded)), $label = $this->randomMachineName($max_length_exceeded), implode(',', array($recipients[0])), '', TRUE);
|
||||
$this->assertText(format_string('Machine-readable name cannot be longer than !max characters but is currently !exceeded characters long.', array('!max' => $max_length, '!exceeded' => $max_length_exceeded)));
|
||||
$this->assertText(format_string('Machine-readable name cannot be longer than @max characters but is currently @exceeded characters long.', array('@max' => $max_length, '@exceeded' => $max_length_exceeded)));
|
||||
$this->addContactForm($id = Unicode::strtolower($this->randomMachineName($max_length)), $label = $this->randomMachineName($max_length), implode(',', array($recipients[0])), '', TRUE);
|
||||
$this->assertRaw(t('Contact form %label has been added.', array('%label' => $label)));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\contact\Tests\Migrate\MigrateContactCategoryTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\contact\Tests\Migrate;
|
||||
|
||||
use Drupal\contact\Entity\ContactForm;
|
||||
use Drupal\contact\ContactFormInterface;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Migrate contact categories to contact.form.*.yml.
|
||||
*
|
||||
* @group contact_category
|
||||
*/
|
||||
class MigrateContactCategoryTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('contact');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('contact_category');
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs various assertions on a single contact form entity.
|
||||
*
|
||||
* @param string $id
|
||||
* The contact form ID.
|
||||
* @param string $expected_label
|
||||
* The expected label.
|
||||
* @param string[] $expected_recipients
|
||||
* The recipient e-mail addresses the form should have.
|
||||
* @param string $expected_reply
|
||||
* The expected reply message.
|
||||
* @param integer $expected_weight
|
||||
* The contact form's expected weight.
|
||||
*/
|
||||
protected function assertEntity($id, $expected_label, array $expected_recipients, $expected_reply, $expected_weight) {
|
||||
/** @var \Drupal\contact\ContactFormInterface $entity */
|
||||
$entity = ContactForm::load($id);
|
||||
$this->assertTrue($entity instanceof ContactFormInterface);
|
||||
$this->assertIdentical($expected_label, $entity->label());
|
||||
$this->assertIdentical($expected_recipients, $entity->getRecipients());
|
||||
$this->assertIdentical($expected_reply, $entity->getReply());
|
||||
$this->assertIdentical($expected_weight, $entity->getWeight());
|
||||
}
|
||||
|
||||
/**
|
||||
* The Drupal 6 and 7 contact categories to Drupal 8 migration.
|
||||
*/
|
||||
public function testContactCategory() {
|
||||
$this->assertEntity('website_feedback', 'Website feedback', ['admin@example.com'], '', 0);
|
||||
$this->assertEntity('some_other_category', 'Some other category', ['test@example.com'], 'Thanks for contacting us, we will reply ASAP!', 1);
|
||||
$this->assertEntity('a_category_much_longer_than_thir', 'A category much longer than thirty two characters', ['fortyninechars@example.com'], '', 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -18,18 +18,16 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
|||
class MigrateContactCategoryTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('contact');
|
||||
public static $modules = ['contact'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d6_contact_category');
|
||||
$this->executeMigration('contact_category');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\contact\Tests\Migrate\d6\MigrateContactConfigsTest.
|
||||
* Contains \Drupal\contact\Tests\Migrate\d6\MigrateContactSettingsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\contact\Tests\Migrate\d6;
|
||||
|
|
@ -15,31 +15,21 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
|||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateContactConfigsTest extends MigrateDrupal6TestBase {
|
||||
class MigrateContactSettingsTest extends MigrateDrupal6TestBase {
|
||||
|
||||
use SchemaCheckTestTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('contact');
|
||||
public static $modules = ['contact'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
// Add some id mappings for the dependent migrations.
|
||||
$id_mappings = array(
|
||||
'd6_contact_category' => array(
|
||||
array(array(1), array('website_feedback')),
|
||||
array(array(2), array('some_other_category')),
|
||||
),
|
||||
);
|
||||
$this->prepareMigrations($id_mappings);
|
||||
$this->executeMigration('d6_contact_settings');
|
||||
$this->executeMigrations(['contact_category', 'd6_contact_settings']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\contact\Tests\Migrate\d7\MigrateContactSettingsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\contact\Tests\Migrate\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Tests migration of Contact settings to configuration.
|
||||
*
|
||||
* @group migrate_drupal_7
|
||||
*/
|
||||
class MigrateContactSettingsTest extends MigrateDrupal7TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['contact'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('contact_category');
|
||||
$this->executeMigration('d7_contact_settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of Contact's variables to configuration.
|
||||
*/
|
||||
public function testContactSettings() {
|
||||
$config = $this->config('contact.settings');
|
||||
$this->assertTrue($config->get('user_default_enabled'));
|
||||
$this->assertIdentical(33, $config->get('flood.limit'));
|
||||
$this->assertEqual('website_testing', $config->get('default_form'));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue