Commit 080e3e1e authored by Adam Shepherd's avatar Adam Shepherd
Browse files

Issue #3502238 by adamps: Transition to 2.x

parent 36ed4b7b
Loading
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
name: Drupal Symfony Mailer Override
type: module
description: 'Overrides email building for key core and contrib modules, improving features and integration with Symfony Mailer.'
core_version_requirement: ^10.3 || ^11
package: Mail
lifecycle: deprecated
lifecycle_link: 'https://www.drupal.org/project/symfony_mailer/issues/3355626'
+9 −4
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ use Symfony\Component\DependencyInjection\Exception\AutowiringFailedException;
 * Extension of \Drupal\Core\DependencyInjection\AutowireTrait.
 * - Add caching to reduce performance issues.
 * - Allow passing extra arguments for the constructor.
 * - Allow optional dependencies.
 */
trait AutowireTrait {

@@ -43,15 +44,19 @@ trait AutowireTrait {
        }

        if (!$container->has($service)) {
          if (!$parameter->allowsNull()) {
            throw new AutowiringFailedException($service, sprintf('Cannot autowire service "%s": argument "$%s" of method "%s::_construct()", you should configure its value explicitly.', $service, $parameter->getName(), static::class));
          }

          static::$services[] = NULL;
        }
        else {
          static::$services[] = $service;
        }
      }
    }

    foreach (static::$services as $service) {
      $args[] = $container->get($service);
      $args[] = $service ? $container->get($service) : NULL;
    }
    return new static(...$args);
  }
+0 −8
Original line number Diff line number Diff line
@@ -260,14 +260,6 @@ class BaseEmail implements BaseEmailInterface {
    return $this->attach(Attachment::fromPath($path, $name, $mimeType));
  }

  /**
   * {@inheritdoc}
   */
  public function attachNoPath(string $body, ?string $name = NULL, ?string $mimeType = NULL) {
    @trigger_error('\Drupal\symfony_mailer\Email::attachNoPath() is deprecated in symfony_mailer:1.6.0 and is removed from symfony_mailer:2.0.0. Use ::attach() instead. See https://www.drupal.org/node/3476132', E_USER_DEPRECATED);
    return $this->attach(Attachment::fromData($body, $name, $mimeType));
  }

  /**
   * {@inheritdoc}
   */
+0 −23
Original line number Diff line number Diff line
@@ -276,29 +276,6 @@ interface BaseEmailInterface {
   */
  public function attachFromPath(string $path, ?string $name = NULL, ?string $mimeType = NULL);

  /**
   * Adds an attachment from temporary content that's not related to a path.
   *
   * If the content comes from a path (such as a local file, or web resource)
   * then use attachFromPath(). This is important to ensure security checking
   * runs based on the correct path.
   *
   * @param string $body
   *   The content of the attachment.
   * @param string|null $name
   *   (optional) The file name.
   * @param string|null $mimeType
   *   (optional) The MIME type. If omitted, the type will be guessed.
   *
   * @return $this
   *
   * @deprecated in symfony_mailer:1.6.0 and is removed from symfony_mailer:2.0.0.
   *   Instead you should use attach().
   *
   * @see https://www.drupal.org/node/3476132
   */
  public function attachNoPath(string $body, ?string $name = NULL, ?string $mimeType = NULL);

  /**
   * Gets the attachments.
   *
+4 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ class TestEmailForm extends FormBase {
   */
  public function __construct(
    protected readonly TestMailerInterface $mailer,
    protected readonly PolicyHelperInterface $helper,
    protected readonly ?PolicyHelperInterface $helper = NULL,
  ) {}

  /**
@@ -50,7 +50,9 @@ class TestEmailForm extends FormBase {
      '#description' => $this->t('Recipient email address. Leave blank to send to yourself.'),
    ];

    if ($this->helper) {
      $form['mailer_policy'] = $this->helper->renderTypePolicy('symfony_mailer');
    }

    $form['actions']['#type'] = 'actions';
    $form['actions']['submit'] = [
Loading