You are here

public static function UpdateHelper::updateToRecipientPlugin in Workbench Email 8

Same name and namespace in other branches
  1. 2.x src/Update/UpdateHelper.php \Drupal\workbench_email\Update\UpdateHelper::updateToRecipientPlugin()

Update helper for migrating from old configuration to recipient plugins.

Parameters

\Drupal\workbench_email\TemplateInterface $template: Template being updated.

Return value

bool TRUE if updates were made.

1 call to UpdateHelper::updateToRecipientPlugin()
UpdateHelper::legacyUpdateToRecipientPlugin in src/Update/UpdateHelper.php
Updates template entities in Drupal core < 8.6.

File

src/Update/UpdateHelper.php, line 50

Class

UpdateHelper
Defines a class for update helpers.

Namespace

Drupal\workbench_email\Update

Code

public static function updateToRecipientPlugin(TemplateInterface $template) {
  $plugins = [];
  if ($template
    ->get('author')) {
    $plugins['author'] = [
      'id' => 'author',
      'provider' => 'workbench_email',
      'status' => TRUE,
      'settings' => [],
    ];
  }
  if ($roles = $template
    ->get('roles')) {
    $plugins['role'] = [
      'id' => 'role',
      'provider' => 'workbench_email',
      'status' => TRUE,
      'settings' => [
        'roles' => $roles,
      ],
    ];
  }
  if ($fields = $template
    ->get('fields')) {
    $plugins['email'] = [
      'id' => 'email',
      'provider' => 'workbench_email',
      'status' => TRUE,
      'settings' => [
        'fields' => $fields,
      ],
    ];
  }
  $template
    ->set('recipient_types', $plugins);
  $template
    ->set('fields', NULL);
  $template
    ->set('roles', NULL);
  $template
    ->set('author', NULL);
  return TRUE;
}