You are here

public function SendinblueBlock::getDerivativeDefinitions in SendinBlue 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Derivative/SendinblueBlock.php \Drupal\sendinblue\Plugin\Derivative\SendinblueBlock::getDerivativeDefinitions()

Provide multiple blocks for sendinblue signup forms.

Overrides DeriverBase::getDerivativeDefinitions

File

src/Plugin/Derivative/SendinblueBlock.php, line 55

Class

SendinblueBlock
Provides block plugin definitions for sendinblue blocks.

Namespace

Drupal\sendinblue\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  $signups = $this->entityTypeManager
    ->getStorage(SendinblueManager::SENDINBLUE_SIGNUP_ENTITY)
    ->loadMultiple();
  foreach ($signups as $signup) {
    if ((int) $signup->mode->value == SendinblueManager::SENDINBLUE_SIGNUP_BLOCK || (int) $signup->mode->value == SendinblueManager::SENDINBLUE_SIGNUP_BOTH) {
      $this->derivatives[$signup->mcsId->value] = $base_plugin_definition;
      $this->derivatives[$signup->mcsId->value]['admin_label'] = $this
        ->t('SendinBlue Subscription Form: @name', [
        '@name' => $signup->name->value,
      ]);
      $this->derivatives[$signup->mcsId->value]['mcsId'] = $signup->mcsId->value;
    }
  }
  return $this->derivatives;
}