سؤال

Is there any way to implement reusable components with Silex, in a similar way like symfony1 had components, and Symfony2 has subrequests? I basically want to capture the output of one or several reusable widgets (which have some logic in their controller) inside another controller.

I found a way to render Twig templates seperately, but I do have some components with an attached business logic.

هل كانت مفيدة؟

المحلول

I'm guessing this is what you need:

A render function is also register to help you render another controller from a template:

{{ render('/sidebar') }}

{# or if you are also using UrlGeneratorServiceProvider #}
{{ render(path('sidebar')) }}

Taken from the Twig provider chapter of the documentation. Checking the source also tells me it makes a subrequest.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top