I personally don't like such things like "context" ... I don't like
that each problem should be solved in the configuration.
It cannot cover each use cases. Then somebody wishes, I need a
configuration that depends on routing pattern
and somebody wishes a configuration depending on special behavior ...

I would implement such thing in this way:

<services>
  <service id="mybundle.mycontroller" class="FooController">
    <argument type="service">
      <service id="request" />
    </argument>
  </service>
  <service id="templating" class="DefaultTemplateEngine" />
  <service id="templating.json" class="JsonTemplateEngine" />
  <service id="templating.xml" class="XmlTemplateEngine" />
</services>

class FooController implements Controller
{
  public function __construct(Request $request)
  {
    if ($request->isJson()) $this->container->setService("templating",
$this->container->getService("templating.json"));
  }
}

or with the route:

foo:
  pattern:  /foo.:_format
  defaults: { _controller: FooController:indexAction, templating:
templating.:_format }

and the controller:

class FooController implements Controller
{
  public function __construct(Request $request)
  {
    if ($this->getRoute()->hasDefault("templating"))
      $container->setService("templating", $this->getRoute()-
>getDefault("templating", "default));
  }
}

The code is written fast without thinking of the right usage of the
Symfony controller classes ...

But it would be my way how to solve this problem and sorry for my typo
errors ...

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to