You are here

protected function CronHandler::getInstagramAccounts in Instagram Feeds 8

Gets active Instagram account entities.

Return value

\Drupal\instagram_feeds\Entity\InstagramAccountInterface[]

2 calls to CronHandler::getInstagramAccounts()
CronHandler::importInstagramPosts in src/CronHandler.php
Cron handler to import Instagram posts for all configured accounts.
CronHandler::refreshTokens in src/CronHandler.php
Refreshes Instagram token as per scheduled frequency.

File

src/CronHandler.php, line 109

Class

CronHandler
Instagram Feeds Cron Handler Service.

Namespace

Drupal\instagram_feeds

Code

protected function getInstagramAccounts() : array {
  if (!isset($this->instagramAccounts)) {
    $this->instagramAccounts = [];
    $instagram_accounts = $this->entityTypeManager
      ->getStorage('instagram_account')
      ->loadMultiple();

    /** @var \Drupal\instagram_feeds\Entity\InstagramAccountInterface $account */
    foreach ($instagram_accounts as $account) {

      // Skip if entity is unpublished or token is invalid.
      if ($account
        ->isPublished() && $account
        ->tokenIsValid()) {
        $this->instagramAccounts[$account
          ->id()] = $account;
      }
    }
  }
  return $this->instagramAccounts;
}