function _instagram_feeds_account_tokens in Instagram Feeds 8
Helper function to process Instagram post tokens.
See also
1 call to _instagram_feeds_account_tokens()
- instagram_feeds_tokens in ./
instagram_feeds.tokens.inc - Implements hook_tokens().
File
- ./
instagram_feeds.tokens.inc, line 97 - Provides Token integration for Instagram Feeds.
Code
function _instagram_feeds_account_tokens(Token $token_service, $tokens, InstagramAccountInterface $i_account, array $options, BubbleableMetadata $bubbleable_metadata) {
$replacements = [];
foreach ($tokens as $name => $original) {
switch ($name) {
case 'username':
$replacements[$original] = $i_account
->label();
break;
case 'id':
$replacements[$original] = $i_account
->id();
break;
case 'author':
$account = $i_account
->getOwner();
$bubbleable_metadata
->addCacheableDependency($account);
$replacements[$original] = $account
->label();
break;
}
}
if ($author_tokens = $token_service
->findWithPrefix($tokens, 'author')) {
$replacements += $token_service
->generate('user', $author_tokens, [
'user' => $i_account
->getOwner(),
], $options, $bubbleable_metadata);
}
return $replacements;
}