2017 © Pedro PelĂĄez
 

library response_manager

A controller response manager for the Silex ”-framework.

image

chanmix51/response_manager

A controller response manager for the Silex ”-framework.

  • Tuesday, April 23, 2013
  • by chanmix51
  • Repository
  • 0 Watchers
  • 0 Stars
  • 6 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Response Manager

What

The Response Manager is a small service provider for the Silex ”-framework that allow http response to be generated at the very end of the process., (*1)

Why

It is sometime usefull to reuse existing controllers. But if the controllers return already generated view, it is very un easy to deal with the values they had nor to extend the application behavior. With the response manager, you get a ControllerResponse from which you can add or remove values that will be sent to the template., (*2)

How

$app->register(new ResponseManager\ControllerResponseServiceProvider());

Now, in your controllers you can do something like:, (*3)

public function controller1()
{
    return $this->app['response_manager']->build('twig', array('path/template.html.twig', array('var1' => 'value1')));
}

public function controller2($something)
{
    $response = $this->controller1();
    $response['something'] = $something;

    return $response;
}

But you can also choose to extract the response's variable and create a new response pointing to another template. The final http response will be created after all the controllers are run., (*4)

Note

Response manager comes with a handy StringControllerResponse if you do not want to use twig for your template:, (*5)

// template.txt
Welcome {{ NAME }}.

public function controller($name)
{
    return $this->app['response_manager']->build('string', array(file_get_contents('template.txt'), array('name' => $name)));
}

The Versions

23/04 2013

dev-master

9999999-dev

A controller response manager for the Silex ”-framework.

  Sources   Download

MIT