Refactor
Try a different way of naming and grouping classes.
This commit is contained in:
parent
52c1b33711
commit
6b6b362a49
15 changed files with 111 additions and 59 deletions
|
@ -5,8 +5,7 @@ declare(strict_types=1);
|
|||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
use Drupal\Core\StringTranslation\TranslatableMarkup;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\opd_podcast\Entity\PodcastEpisode;
|
||||
use Drupal\taxonomy\TermInterface;
|
||||
use Drupal\opd_podcast\PodcastEpisode;
|
||||
|
||||
/**
|
||||
* Implements hook_entity_bundle_info_alter().
|
||||
|
@ -86,20 +85,7 @@ function opd_podcast_tokens(string $type, array $tokens, array $data, array $opt
|
|||
$node = $data['node'] ?? NULL;
|
||||
assert($node instanceof PodcastEpisode);
|
||||
|
||||
$guests = $node->getGuests();
|
||||
assert(is_array($guests));
|
||||
assert(!is_null($guests[0]));
|
||||
assert($guests[0] instanceof TermInterface);
|
||||
|
||||
// TODO: allow for more than two guests.
|
||||
if (count($guests) === 2) {
|
||||
assert($guests[1] instanceof TermInterface);
|
||||
|
||||
$replacements[$original] = sprintf('%s %s %s', $guests[0]->label(), t('and'), $guests[1]->label());
|
||||
break;
|
||||
}
|
||||
|
||||
$replacements[$original] = $guests[0]->label();
|
||||
$replacements[$original] = strval($node->getGuests());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue