/** * @param string $serviceid * @param \Silex\Controller $controller * @param \Silex\Application $app * @param \ReflectionClass $class * @param \ReflectionMethod $method * @return mixed */ public function modify($serviceid, Controller $controller, Application $app, \ReflectionClass $class, \ReflectionMethod $method) { echo "<pre>In " . __METHOD__ . " (annotation modification for {$class->getName()}::{$method->getName()}...</pre>"; $controller->before(function () { echo "<pre>In Callback Induced From @Test Annotation...</pre>"; }); }
/** * @param string $serviceid * @param \Silex\Controller $controller * @param \Silex\Application $app * @param \ReflectionClass $class * @param \ReflectionMethod $method * @return mixed|void */ public function modify($serviceid, Controller $controller, Application $app, \ReflectionClass $class, \ReflectionMethod $method) { $callback = $this->callback; if (!is_callable($callback)) { if ($class->hasMethod($callback)) { $callback = [$app[$serviceid], $callback]; } } $controller->before($callback); }
private function configureController(Controller $controller, $route_name = null, $before = null, $after = null) { if ($route_name) { $controller->bind($route_name); } if ($before) { $controller->before($this->callback_prefix . ":" . $before); } if ($after) { $controller->after($this->callback_prefix . ":" . $after); } }
/** * @param \Silex\Controller $controller * * @return void */ private function addJsonParsing(Controller $controller) { $controller->before(function (Request $request) { $isJson = strpos($request->headers->get('Content-Type'), 'application/json') === 0; if ($isJson) { $data = json_decode($request->getContent(), true); $request->request->replace(is_array($data) ? $data : []); } }); }