Skip to content

Instantly share code, notes, and snippets.

@yahyaerturan
Created April 24, 2019 08:53
Show Gist options
  • Save yahyaerturan/675daa234c0a9e07923fa39ab030afd7 to your computer and use it in GitHub Desktop.
Save yahyaerturan/675daa234c0a9e07923fa39ab030afd7 to your computer and use it in GitHub Desktop.
<?php
namespace App\EventSubscriber;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Routing\RouterInterface;
use Twig\Environment;
class BaseEventSubscriber
{
/**
* @var RouterInterface
*/
private $router;
/**
* @var MessageBusInterface
*/
private $messageBus;
/**
* @var Environment
*/
private $twig;
public function __construct(MessageBusInterface $messageBus, RouterInterface $router, Environment $twig)
{
$this->router = $router;
$context = $this->router->getContext();
$context->setHost(getenv('BASE_URL'));
$context->setScheme(getenv('SCHEMA'));
$context->setBaseUrl('');
$context->setParameter('_locale', 'tr_TR');
$this->messageBus = $messageBus;
$this->twig = $twig;
}
/**
* @return RouterInterface
*/
public function getRouter(): RouterInterface
{
return $this->router;
}
/**
* @return MessageBusInterface
*/
public function getMessageBus(): MessageBusInterface
{
return $this->messageBus;
}
/**
* @return Environment
*/
public function getTwig(): Environment
{
return $this->twig;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment