Skip to content

Commit

Permalink
Added some pre and post hooks to controllers.
Browse files Browse the repository at this point in the history
  • Loading branch information
seeruk committed Aug 30, 2014
1 parent e9bf2e8 commit d8e4270
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Trident/Component/HttpKernel/AbstractKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ abstract class AbstractKernel implements HttpKernelInterface
protected $session;
protected $startTime;

const VERSION = '1.0.6-alpha';
const VERSION = '1.0.6-alpha2';
const VERSION_ID = '10006';
const MAJOR_VERSION = '1';
const MINOR_VERSION = '0';
const RELEASE_VERSION = '6';
const EXTRA_VERSION = 'alpha';
const EXTRA_VERSION = 'alpha2';

/**
* Constructor.
Expand Down Expand Up @@ -141,9 +141,17 @@ protected function handleRequest(Request $request, $type)
$event->setArguments($arguments);
$this->getDispatcher()->dispatch(KernelEvents::CONTROLLER, $event);

if (method_exists($controller, 'preAction')) {
$controller->preAction();
}

// Attempt to get a response from the controller
$response = call_user_func_array($controller, $arguments);

if (method_exists($controller, 'postAction')) {
$controller->postAction();
}

if ( ! $response instanceof Response) {
$message = sprintf('The controller must return a valid Response (%s given).', $this->varToString($response));

Expand Down

0 comments on commit d8e4270

Please sign in to comment.