<?php
namespace Roothirsch\CoreBundle\Site;
use Roothirsch\CoreBundle\Site\Repository\SiteRepository;
use Symfony\Component\HttpFoundation\RequestStack;
class SiteProvider
{
/**
* @var Entity\Site|null
*/
private $site;
/**
* Undocumented variable
*
* @var Request
*/
protected $request;
/**
* @return string
*/
public function getTitle()
{
return $this->site->getTitle();
}
/**
* @return string
*/
public function getLogo()
{
return $this->site->getLogo();
}
/**
* @return string
*/
public function getTheme()
{
if(!$this->request){
return $this->site->getTheme();
}
$overrideTheme = $this->request->get('_override_theme', false);
if ($overrideTheme !== false) {
return $overrideTheme;
}
return $this->site->getTheme();
}
public function getWebsite(){
return $this->site->getWebsite();
}
public function getHostUrl(){
return $this->request->server->get("HTTP_ORIGIN");
}
public function getAddress(){
return $this->site->getAddress();
}
public function getCompany(){
return $this->site->getCompany();
}
/**
* SettingsProvider constructor.
*/
public function __construct(SiteRepository $repository, RequestStack $requestStack)
{
$this->site = $repository->findOneBy(["id"=>1]);
$this->request = $requestStack->getCurrentRequest();
}
}