From 91303a0b17b6ca06028d4745a454432d3d677a08 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 26 Nov 2019 09:53:18 +0100 Subject: [PATCH] refactor boh --- podcast_ror.routing.yml | 9 +++++++++ src/Controller/PodcastRorController.php | 17 +++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/podcast_ror.routing.yml b/podcast_ror.routing.yml index 34614d8..26607d0 100644 --- a/podcast_ror.routing.yml +++ b/podcast_ror.routing.yml @@ -7,3 +7,12 @@ podcast_ror.all: _access: 'TRUE' options: no_cache: 'TRUE' +podcast_ror.any: + path: '/podcast/{ctype}.xml' + defaults: + _controller: '\Drupal\podcast_ror\Controller\PodcastRorController::podcastAny' + _title: 'Podcast for any type' + requirements: + _access: 'TRUE' + options: + no_cache: 'TRUE' diff --git a/src/Controller/PodcastRorController.php b/src/Controller/PodcastRorController.php index 26d14bc..a3c1f14 100644 --- a/src/Controller/PodcastRorController.php +++ b/src/Controller/PodcastRorController.php @@ -5,6 +5,7 @@ use Drupal\Core\Controller\ControllerBase; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Template\TwigEnvironment; +use Drupal\node\NodeInterface; class PodcastRorController extends ControllerBase { protected $state; @@ -48,6 +49,7 @@ class PodcastRorController extends ControllerBase { $data['nodes'][$nid]['img'] = array(); foreach( $node->get('field_contenuti_audio')->referencedEntities() as $ai => $entity) { $data['nodes'][$nid]['audio'][$ai] = $entity->toArray(); + //$data['nodes'][$nid]['audio'][$ai]['text'] = print_r($data['nodes'][$nid]['audio'][$ai]['field_audio_link'], true); } foreach( $node->get('field_image')->referencedEntities() as $ai => $entity) { $arr = $entity->toArray(); @@ -63,15 +65,22 @@ class PodcastRorController extends ControllerBase { } return $data; } - public function podcastAll() { + public function podcast($path) { + // TODO: use $path $template = $this->twig->loadTemplate(drupal_get_path('module', 'podcast_ror') . '/templates/podcast.html.twig'); $tmpl_data = [ 'ror' => array('podcast' => $this->query(), 'url' => \Drupal::service('path.current')->getPath(), )]; - $variables['ror']['url'] = + //$variables['ror']['url'] = $xml = $template->render($tmpl_data); - $resp = new Response($xml, 200, array( - 'Content-Type' => 'application/rss+xml')); + $resp = new Response($xml, 200, array( 'Content-Type' => 'application/rss+xml')); return $resp; } + public function podcastAll() { + return $this->podcast('all.xml'); + } + public function podcastAny(NodeInterface $ctype) { + return new Response('tipo: BOH', 200,array( 'Content-Type' => 'application/rss+xml')); + // return $this->podcast($ctype); + } }