You are here

protected function FeedQueueWorkerBase::switchAccount in Feeds 8.3

Safely switches to another account.

Parameters

\Drupal\feeds\FeedInterface $feed: The feed that has the account to switch to.

Return value

\Drupal\Core\Session\AccountSwitcherInterface The account switcher to call switchBack() on.

See also

\Drupal\Core\Session\AccountSwitcherInterface::switchTo()

File

src/Plugin/QueueWorker/FeedQueueWorkerBase.php, line 108

Class

FeedQueueWorkerBase
Base class for Feed queue workers.

Namespace

Drupal\feeds\Plugin\QueueWorker

Code

protected function switchAccount(FeedInterface $feed) {
  $account = new AccountProxy($this
    ->getEventDispatcher());
  $account
    ->setInitialAccountId($feed
    ->getOwnerId());
  return $this->accountSwitcher
    ->switchTo($account);
}