refactor boh

This commit is contained in:
root 2019-11-26 09:53:18 +01:00
parent f1673636ba
commit 91303a0b17
2 changed files with 22 additions and 4 deletions

View file

@ -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'

View file

@ -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);
}
}