I am creating a Subdomain Listener as per this discussion Symfony2 Routing - route subdomains
So it goes to this listener and I can do the stuff I want to.
But I am not able to extend this listener with one of my controllers. listener code goes like this ...
namespace Acme\FrontEndBundle\Listener;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Response;
use Acme\BraPrintBundle\Controller\BraPrintController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
class SubdomainListener extends BraPrintController
{
public function onDomainParse(Event $event)
{
$request = $event->getRequest();
$session = $request->getSession();
echo $request->getHost();
echo $this->isLoggedIn(); // defined in BraprintController
// todo: parsing subdomain to detect country
//do some auth stuff
//$session->set('corporate', $request->getHost());
}
}
But when I try to run it throws
Fatal error: Call to a member function get() on a non-object in /home/myname/myproject/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php on line 192
So when I try to debug it actully goes through extended classes but at the end in Controller its not able to deal with get().
Is there a work around to access controller functions in Listener ?