Refactor
This commit is contained in:
parent
9308ce76a5
commit
51299096c5
5 changed files with 48 additions and 29 deletions
|
@ -5,7 +5,8 @@ declare(strict_types=1);
|
|||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
use Drupal\Core\StringTranslation\TranslatableMarkup;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\opd_podcast\PodcastEpisode;
|
||||
use Drupal\opd_podcast\Episode;
|
||||
use Drupal\opd_podcast\Guest;
|
||||
|
||||
/**
|
||||
* Implements hook_entity_bundle_info_alter().
|
||||
|
@ -14,7 +15,11 @@ use Drupal\opd_podcast\PodcastEpisode;
|
|||
*/
|
||||
function opd_podcast_entity_bundle_info_alter(array &$bundles): void {
|
||||
if (isset($bundles['node'])) {
|
||||
$bundles['node'][PodcastEpisode::NODE_TYPE]['class'] = PodcastEpisode::class;
|
||||
$bundles['node'][Episode::NODE_TYPE]['class'] = Episode::class;
|
||||
}
|
||||
|
||||
if (isset($bundles['taxonomy_term'])) {
|
||||
$bundles['taxonomy_term'][Guest::TERM_TYPE]['class'] = Guest::class;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +28,7 @@ function opd_podcast_entity_bundle_info_alter(array &$bundles): void {
|
|||
* @param array<non-empty-string, mixed> $context
|
||||
*/
|
||||
function opd_podcast_node_links_alter(array &$links, NodeInterface $entity, array &$context): void {
|
||||
if (!$entity instanceof PodcastEpisode) {
|
||||
if (!$entity instanceof Episode) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -83,7 +88,7 @@ function opd_podcast_tokens(string $type, array $tokens, array $data, array $opt
|
|||
switch ($name) {
|
||||
case 'guest-names':
|
||||
$node = $data['node'] ?? NULL;
|
||||
assert($node instanceof PodcastEpisode);
|
||||
assert($node instanceof Episode);
|
||||
|
||||
$replacements[$original] = strval($node->getGuests());
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue