Файл: forsoc.ru/ext/shredder/sitemap/controller/sitemap.php
Строк: 102
<?php
/**
*
* @package phpBB3 SEO Sitemap
* @copyright (c) 2014 www.phpbb-work.ru
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
namespace shreddersitemapcontroller;
use SymfonyComponentHttpFoundationResponse;
use SymfonyComponentHttpKernelExceptionNotFoundHttpException;
class sitemap
{
/**
* Constructor
* NOTE: The parameters of this method must match in order and type with
* the dependencies defined in the services.yml file for this service.
*
/** @var shreddersitemapcore */
protected $core;
/** @var shreddersitemapappender */
protected $appender;
/** @var phpbbcacheservice */
protected $cache;
/** @var phpbbconfigconfig */
protected $config;
/** @var phpbbuser */
private $user;
public function __construct(shreddersitemapappender $appender, shreddersitemapcore $core, phpbbcacheservice $cache, phpbbconfigconfig $config, phpbbuser $user)
{
$this->core = $core;
$this->cache = $cache;
$this->config = $config;
$this->user = $user;
$this->appender = $appender;
}
/**
* Controller for route /sitemap/
*
* @param string $name
* @return SymfonyComponentHttpFoundationResponse A Symfony Response object
*/
public function display_sitemap()
{
$driver = $this->cache->get_driver();
if (($f_xml = $driver->get("_sitemap_seo_file")) === false)
{
$f_xml = $this->core->generate_sitemap();
if (false == $f_xml)
{
throw new NotFoundHttpException($this->user->lang['SEOMAP_NO_DATA']);
}
$this->config->set('sitemap_seo_url_count', $this->appender->getUrlCount());
if ($this->config['sitemap_seo_cache'])
{
$driver->put("_sitemap_seo_file", $f_xml, 3600*$this->config['sitemap_seo_cache']);
}
}
$response = new Response($f_xml);
$response->headers->set('Content-Type', 'application/xml');
return $response;
}
public function display_sitemap_seqno_file($seqno)
{
$f_xml = $this->core->sitemap_file_get_contents($seqno);
if (false == $f_xml)
{
throw new NotFoundHttpException(sprintf($this->user->lang['SEOMAP_NO_FILE'], generate_board_url() . '/store/shredder/' . $seqno . '.xml'));
}
$response = new Response($f_xml);
$response->headers->set('Content-Type', 'application/xml');
return $response;
}
}