refactor boh
This commit is contained in:
parent
f1673636ba
commit
91303a0b17
2 changed files with 22 additions and 4 deletions
|
@ -7,3 +7,12 @@ podcast_ror.all:
|
||||||
_access: 'TRUE'
|
_access: 'TRUE'
|
||||||
options:
|
options:
|
||||||
no_cache: 'TRUE'
|
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'
|
||||||
|
|
|
@ -5,6 +5,7 @@ use Drupal\Core\Controller\ControllerBase;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Drupal\Core\Template\TwigEnvironment;
|
use Drupal\Core\Template\TwigEnvironment;
|
||||||
|
use Drupal\node\NodeInterface;
|
||||||
|
|
||||||
class PodcastRorController extends ControllerBase {
|
class PodcastRorController extends ControllerBase {
|
||||||
protected $state;
|
protected $state;
|
||||||
|
@ -48,6 +49,7 @@ class PodcastRorController extends ControllerBase {
|
||||||
$data['nodes'][$nid]['img'] = array();
|
$data['nodes'][$nid]['img'] = array();
|
||||||
foreach( $node->get('field_contenuti_audio')->referencedEntities() as $ai => $entity) {
|
foreach( $node->get('field_contenuti_audio')->referencedEntities() as $ai => $entity) {
|
||||||
$data['nodes'][$nid]['audio'][$ai] = $entity->toArray();
|
$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) {
|
foreach( $node->get('field_image')->referencedEntities() as $ai => $entity) {
|
||||||
$arr = $entity->toArray();
|
$arr = $entity->toArray();
|
||||||
|
@ -63,15 +65,22 @@ class PodcastRorController extends ControllerBase {
|
||||||
}
|
}
|
||||||
return $data;
|
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');
|
$template = $this->twig->loadTemplate(drupal_get_path('module', 'podcast_ror') . '/templates/podcast.html.twig');
|
||||||
$tmpl_data = [ 'ror' => array('podcast' => $this->query(),
|
$tmpl_data = [ 'ror' => array('podcast' => $this->query(),
|
||||||
'url' => \Drupal::service('path.current')->getPath(),
|
'url' => \Drupal::service('path.current')->getPath(),
|
||||||
)];
|
)];
|
||||||
$variables['ror']['url'] =
|
//$variables['ror']['url'] =
|
||||||
$xml = $template->render($tmpl_data);
|
$xml = $template->render($tmpl_data);
|
||||||
$resp = new Response($xml, 200, array(
|
$resp = new Response($xml, 200, array( 'Content-Type' => 'application/rss+xml'));
|
||||||
'Content-Type' => 'application/rss+xml'));
|
|
||||||
return $resp;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue