You are here

public function SendinblueManager::generateHomeLogin in SendinBlue 8.2

Same name and namespace in other branches
  1. 8 src/SendinblueManager.php \Drupal\sendinblue\SendinblueManager::generateHomeLogin()

Generate Home layout of Log out.

Return value

array A html of home page when login.

File

src/SendinblueManager.php, line 309

Class

SendinblueManager
Basic manager of module.

Namespace

Drupal\sendinblue

Code

public function generateHomeLogin() {

  // Calculate total count of subscribers.
  $lists = $this->sendinblueMailin
    ->getLists();
  $totalSubscribers = 0;
  $listIds = [];
  if ($lists
    ->getCount() > 0) {
    $listData = $lists
      ->getLists();
    foreach ($listData as $list) {
      $listIds[] = $list['id'];
    }
    $totalSubscribers = $this->sendinblueMailin
      ->countUserlists($listIds);
  }

  // Get account details.
  $accountEmail = $this
    ->getAccountEmail();
  $accountUsername = $this
    ->getAccountUsername();
  $account_data = Json::decode($this
    ->getAccountData());
  $sendinblue_logout_form = $this->formBuilder
    ->getForm(LogoutForm::class);
  $sendinblue_send_email_form = $this->formBuilder
    ->getForm(TransactionnalEmailForm::class);
  $sendinblue_user_register_form = $this->formBuilder
    ->getForm(RegisteringUserForm::class);
  return [
    '#account_username' => [
      '#plain_text' => $accountUsername,
    ],
    '#account_email' => [
      '#plain_text' => $accountEmail,
    ],
    '#total_subscribers' => [
      '#plain_text' => $totalSubscribers,
    ],
    '#account_data' => $account_data,
    '#api_version' => $this
      ->getApiVersion($this
      ->getAccessKey()),
    '#sendinblue_logout_form' => $this->renderer
      ->render($sendinblue_logout_form),
    '#sendinblue_send_email_form' => $this->renderer
      ->render($sendinblue_send_email_form),
    '#sendinblue_user_register_form' => $this->renderer
      ->render($sendinblue_user_register_form),
  ];
}