/** * Tests template discovery using namespaces. */ public function testTemplateDiscovery() { // Tests resolving namespaced templates in modules. $this->assertTwigTemplate($this->twig->resolveTemplate('@node/node.html.twig'), 'Found node.html.twig in node module.'); // Tests resolving namespaced templates in themes. $this->assertTwigTemplate($this->twig->resolveTemplate('@bartik/page.html.twig'), 'Found page.html.twig in Bartik theme.'); }
/** * Provides the sitemap in XML format. * * @throws NotFoundHttpException * * @return \Symfony\Component\HttpFoundation\Response * The sitemap in XML format or plain text if xmlsitemap_developer_mode flag * is set. */ public function renderSitemapXml() { $sitemap = $this->entityManager->getStorage('xmlsitemap')->loadByContext(); if (!$sitemap) { throw new NotFoundHttpException(); } $chunk = xmlsitemap_get_current_chunk($sitemap); $file = xmlsitemap_sitemap_get_file($sitemap, $chunk); // Provide debugging information if enabled. if ($this->state->get('xmlsitemap_developer_mode')) { $module_path = drupal_get_path('module', 'xmlsitemap'); $template = $this->twig->loadTemplate($module_path . '/templates/sitemap-developer-mode.html.twig'); $elements = array('current_context' => print_r($context, TRUE), 'sitemap' => print_r($sitemap, TRUE), 'chunk' => $chunk, 'cache_file_location' => $file, 'cache_file_exists' => file_exists($file) ? 'Yes' : 'No'); return new Response($template->render($elements)); } $response = new Response(); return xmlsitemap_output_file($response, $file); }
/** * Tests template discovery using the Drupal theme registry. */ public function testTemplateDiscovery() { $this->assertTwigTemplate($this->twig->resolveTemplate('block.html.twig'), 'Found block.html.twig in block module.'); }