Skip to content
Snippets Groups Projects
Commit 401a8a52 authored by Urvashi Vora's avatar Urvashi Vora Committed by Adam Shepherd
Browse files

Issue #3228605 by AdamPS, urvashi_vora: Fix Drupal coding standards

parent f870907d
Branches
Tags
No related merge requests found
Showing
with 120 additions and 18 deletions
......@@ -82,7 +82,7 @@ class MailManagerReplacement extends MailManager {
'id' => $module . '_' . $key,
'module' => $module,
'key' => $key,
'to' => $to ?: null,
'to' => $to ?: NULL,
'langcode' => $langcode,
'params' => $params,
'reply-to' => $reply,
......
......@@ -38,6 +38,8 @@ class LegacyEmailBuilder extends EmailBuilderBase implements ContainerFactoryPlu
];
/**
* Constructor.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
......
......@@ -83,7 +83,8 @@ class UpdateEmailBuilder extends EmailBuilderBase {
* {@inheritdoc}
*/
public function import() {
// Get without overrides to avoid the dummy value set by MailerBcConfigOverride.
// Get without overrides to avoid the dummy value
// set by MailerBcConfigOverride.
$mail_notification = implode(',', $this->helper()->config()->get('update.settings')->getOriginal('notification.emails', FALSE));
if ($mail_notification) {
......
name: 'Theme for testing BC template rendering'
type: theme
description: 'Test theme which provides an alternative template for BC test mail.'
version: VERSION
base theme: stark
core_version_requirement: ^9.1
......@@ -150,7 +150,9 @@ class Address implements AddressInterface {
* @internal
*/
public function __serialize() {
return [$this->email, $this->displayName, $this->langcode, $this->account ? $this->account->id() : NULL];
return [$this->email, $this->displayName, $this->langcode,
$this->account ? $this->account->id() : NULL,
];
}
/**
......
......@@ -51,16 +51,22 @@ class Email implements InternalEmailInterface {
protected $themeManager;
/**
* The type.
*
* @var string
*/
protected $type;
/**
* The subtype.
*
* @var string
*/
protected $subType;
/**
* The config entity.
*
* @var \Drupal\Core\Config\Entity\ConfigEntityInterface
*/
protected $entity;
......@@ -73,6 +79,8 @@ class Email implements InternalEmailInterface {
protected $phase = self::PHASE_INIT;
/**
* The body array.
*
* @var array
*/
protected $body = [];
......@@ -92,21 +100,29 @@ class Email implements InternalEmailInterface {
protected $subjectReplace;
/**
* The processors.
*
* @var array
*/
protected $processors = [];
/**
* The language code.
*
* @var string
*/
protected $langcode;
/**
* The params.
*
* @var string[]
*/
protected $params = [];
/**
* The variables.
*
* @var string[]
*/
protected $variables = [];
......@@ -119,11 +135,15 @@ class Email implements InternalEmailInterface {
protected $account;
/**
* The theme.
*
* @var string
*/
protected $theme = '';
/**
* The libraries.
*
* @var array
*/
protected $libraries = [];
......@@ -553,14 +573,24 @@ class Email implements InternalEmailInterface {
*/
public function __serialize() {
// Exclude $this->params, $this->variables as they may not serialize.
return [$this->type, $this->subType, $this->entity ? $this->entity->id() : '', $this->phase, $this->subject, $this->langcode, $this->account ? $this->account->id() : '', $this->theme, $this->libraries, $this->transportDsn, $this->inner, $this->addresses, $this->sender];
return [$this->type, $this->subType,
$this->entity ? $this->entity->id() : '',
$this->phase, $this->subject, $this->langcode,
$this->account ? $this->account->id() : '', $this->theme,
$this->libraries, $this->transportDsn, $this->inner,
$this->addresses, $this->sender,
];
}
/**
* {@inheritdoc}
*/
public function __unserialize(array $data) {
[$this->type, $this->subType, $entity_id, $this->phase, $this->subject, $this->langcode, $account_id, $this->theme, $this->libraries, $this->transportDsn, $this->inner, $this->addresses, $this->sender] = $data;
[$this->type, $this->subType, $entity_id, $this->phase,
$this->subject, $this->langcode, $account_id, $this->theme,
$this->libraries, $this->transportDsn, $this->inner,
$this->addresses, $this->sender,
] = $data;
if ($entity_id) {
$this->entity = $this->configFactory->get($entity_id);
......
......@@ -64,12 +64,53 @@ class MailerPolicy extends ConfigEntityBase implements EntityWithPluginCollectio
*/
protected $emailAdjusterManager;
/**
* The label for an unknown value.
*
* @var string
*/
protected $labelUnknown;
/**
* The label for all values.
*
* @var string
*/
protected $labelAll;
/**
* The type.
*
* @var string
*/
protected $type;
/**
* The subtype.
*
* @var string
*/
protected $subType;
/**
* The entity id.
*
* @var string
*/
protected $entityId;
/**
* The entity.
*
* @var \Drupal\Core\Config\Entity\ConfigEntityInterface
*/
protected $entity;
/**
* The builder definition.
*
* @var string[]
*/
protected $builderDefinition;
/**
......
......@@ -21,8 +21,18 @@ class MailerPolicyListBuilder extends ConfigEntityListBuilder implements MailerP
*/
protected $overrideEntities;
/**
* The type to filter results by.
*
* @var string
*/
protected $filterType;
/**
* The columns to hide.
*
* @var string[]
*/
protected $hideColumns = [];
/**
......@@ -65,7 +75,7 @@ class MailerPolicyListBuilder extends ConfigEntityListBuilder implements MailerP
public function getDefaultOperations(EntityInterface $entity) {
if ($entity->isNew()) {
$operations['create'] = [
'title' => t('Create'),
'title' => $this->t('Create'),
'weight' => -10,
'url' => $this->ensureDestination(Url::fromRoute('entity.mailer_policy.add_id_form', ['policy_id' => $entity->id()])),
];
......
......@@ -57,14 +57,14 @@ abstract class AddressAdjusterBase extends EmailAdjusterBase {
foreach ($addresses as $item) {
$form_item['value'] = [
'#type' => 'textfield',
'#title' => t('Address'),
'#title' => $this->t('Address'),
'#default_value' => $item['value'] ?? NULL,
'#description' => $this->t('Enter an email address, a user ID, or %site to use the site email address.', ['%site' => '<site>']),
];
$form_item['display'] = [
'#type' => 'textfield',
'#title' => t('Display name'),
'#title' => $this->t('Display name'),
'#default_value' => $item['display'] ?? NULL,
'#description' => $this->t('Human-readable display name (ignored for user or site address).'),
];
......
......@@ -37,6 +37,8 @@ class InlineCssEmailAdjuster extends EmailAdjusterBase implements ContainerFacto
protected $cssInliner;
/**
* Constructor.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
......
......@@ -12,11 +12,15 @@ use Drupal\symfony_mailer\EmailInterface;
trait TokenProcessorTrait {
/**
* The data for token replacement.
*
* @var array
*/
protected $data;
/**
* The options for token replacement.
*
* @var array
*/
protected $options = [];
......
......@@ -19,6 +19,11 @@ class MailerTestService implements MailerTestServiceInterface, EmailProcessorInt
*/
protected $state;
/**
* The emails that have been sent.
*
* @var \Drupal\symfony_mailer\EmailInterface[]
*/
protected $emails = [];
/**
......
......@@ -2,8 +2,6 @@
namespace Drupal\symfony_mailer_test;
use Drupal\symfony_mailer\EmailInterface;
/**
* Tracks sent emails for testing.
*/
......
......@@ -2,16 +2,23 @@
namespace Drupal\symfony_mailer_test;
use Drupal\Core\DestructableInterface;
use Drupal\symfony_mailer\EmailInterface;
use Drupal\symfony_mailer_test\MailerTestServiceInterface;
/**
* Tracks sent emails for testing.
*/
trait MailerTestTrait {
/**
* The emails that have been sent and not yet checked.
*
* @var \Drupal\symfony_mailer\EmailInterface[]
*/
protected $emails;
/**
* The most recently sent email.
*
* @var \Drupal\symfony_mailer\EmailInterface
*/
protected $email;
/**
......@@ -24,6 +31,7 @@ trait MailerTestTrait {
$this->init();
$this->email = array_shift($this->emails);
$this->assertNotNull($this->email);
return $this->email;
}
/**
......@@ -90,8 +98,6 @@ trait MailerTestTrait {
/**
* Checks there are no more emails.
*
* @return $this
*/
protected function noMail() {
$this->init();
......@@ -100,6 +106,9 @@ trait MailerTestTrait {
unset($this->emails);
}
/**
* Initializes the list of emails.
*/
protected function init() {
if (is_null($this->emails)) {
$this->emails = \Drupal::state()->get(MailerTestServiceInterface::STATE_KEY, []);
......
......@@ -6,7 +6,6 @@
*/
use Drupal\symfony_mailer\EmailInterface;
use Drupal\symfony_mailer_test\MailerTest;
/**
* Implements hook_mailer_init().
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment