Commit d0ae19be authored by Adam Shepherd's avatar Adam Shepherd
Browse files

Issue #3281120 by AdamPS: Allow configuring mailer policy when adding contact form or newsletter

parent 9250683d
Loading
Loading
Loading
Loading
+4 −0
Changes for modules/symfony_mailer_bc/symfony_mailer_bc.module: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -104,6 +104,10 @@ function symfony_mailer_bc_form_alter(&$form, FormStateInterface $form_state, $f
    ],
  ];

  // Add forms same as edit.
  $config_all['contact_form_add_form'] = $config_all['contact_form_edit_form'];
  $config_all['simplenews_newsletter_add_form'] = $config_all['simplenews_newsletter_edit_form'];

  if ($config = $config_all[$form_id] ?? NULL) {
    $helper = Drupal::service('symfony_mailer.helper');

+5 −2
Changes for src/MailerHelper.php: 5 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -130,9 +130,12 @@ class MailerHelper implements MailerHelperInterface {
   */
  public function renderEntityPolicy(ConfigEntityInterface $entity, string $subtype) {
    $type = $entity->getEntityTypeId();
    $element = $this->renderCommon($type);
    $policy_id = "$type.$subtype";
    $entities = [$policy_id, $policy_id . '.' . $entity->id()];
    $entities = [$policy_id];
    if (!$entity->isNew()) {
      $entities[] = $policy_id . '.' . $entity->id();
    }
    $element = $this->renderCommon($type);
    $element['listing'] = $this->entityTypeManager->getListBuilder('mailer_policy')
      ->overrideEntities($entities)
      ->hideColumns(['type', 'sub_type'])