0

I'm having an issue that I've been banging my head on the wall since the last 3 days (and google/stackoverflow research didn't give much result).

I'm currently maintaining an application developed by another developer (the original developer left). The application is in Symfony 2.6. Within it, there's a logic that handle de access through the concept of Voter. The application logic goes as is: The URL contain the customer(application) name. For instance, let's name our customer TEST. The url would be: myapplication.com/Test When accessing this URL, there's an EventListner (connected onKernelRequest, 31) that get the request and attach the customer to the router context. Here:

if (!$event->isMasterRequest()) { return; }

$request = $event->getRequest();
$requestContext = $this->router->getContext();

if ($company = $request->attributes->get('company')) {
   $requestContext->setParameter('company', $company);
}

This basically allow us to load our providers service by passing the argument

<argument type="expression">service('request_stack').getCurrentRequest().get('company')</argument>

The reason for that is because our application have it's own database (default) and each customer have it's own (since they're generated by a third party ETL, we only have control on segments of those database).

Now the voter definition in the service depend on one of those provider. We basically fetch the list of possible permission (map) from the database of the customer (they change per customer). Unfortunately, at the moment, the whole thing crash. I get the "No mapping file found named ..." error. He's trying to get the file from the default mapping file instead of the client mapping folder.

I've "hacked" the appdebugProjectContainer and added a print_r()|die to display the requestStack entirely and it seems completely empty. (So the request is not even pre-processed at all). Is there something I don't understand?

Wouter J
  • 41,455
  • 15
  • 107
  • 112
  • what's the specific error you're getting with the no mapping file found? – Jason Roman Dec 14 '14 at 19:00
  • What do you means by "specific"? The file doesn't exist because the loading of the repository service is done by passing the request_stack (see the declaration of argument in my post). Because the service_stack doesn't contain the company (I don't know why, the URL does contain it), he goes loading the default doctrine manager instead of the company manager. – Loïc Lavoie Dec 14 '14 at 22:20
  • I mean what file, you never specified. Ate the entity managers defined explicitly in your config.yml for reach company, or is that dynamic as well? What line of code actually produces the error? It feels like there might be a simpler solution here – Jason Roman Dec 14 '14 at 22:32
  • Here's the thing, I don't know what line of code cause the error, it happen in the compiled version. Basically, something is calling the instanciation of the voter which in turn call the CompanyConfiguration service. Unfortunately, that service rely on the parameter found in the URL to load the appropriate doctrine manager. – Loïc Lavoie Dec 14 '14 at 23:34
  • Without additional information it's really difficult to debug where your problem is coming from. – Jason Roman Dec 15 '14 at 00:52

0 Answers0