/**
  * Registers services on the given app.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param Application $app
  */
 public function register(Application $app)
 {
     $app['error.controller'] = $controller = new ErrorController($app);
     $app->error([$controller, 'onApiProblemException']);
     $app->error([$controller, 'whenNotFound']);
     $app->error([$controller, 'whenNotAllowed']);
     $app->error([$controller, 'onHttpException']);
     $app->error([$controller, 'onGeneralException']);
 }
 /**
  * Setup error handlers
  */
 protected function setupErrorHandlers()
 {
     $this->app->error(function (\Exception $e, $code) {
         $data = array('status' => $code);
         if ($this->app['config']('app.debug', false)) {
             $data['error'] = $e->getMessage();
         }
         return $this->app->json($data, $code);
     });
 }
 /**
  * @inheritdoc
  */
 public function register(Application $app)
 {
     $provider = $this;
     $app->error(function (ValidationException $e) use($provider) {
         $problem = new ApiProblem($e->getMessage());
         $problem['validation_messages'] = $e->getErrors();
         return $provider->createBadRequestResponse($problem);
     });
     $app->error(function (InvalidNativeArgumentException $e) use($provider) {
         $problem = new ApiProblem($e->getMessage());
         return $provider->createBadRequestResponse($problem);
     });
 }
Example #4
0
 /**
  * Define error handler
  */
 private function defineErrorHandler()
 {
     $this->app->error(function (\Exception $e, $code) {
         if ($this->app['debug']) {
             return null;
         }
         switch ($code) {
             case 404:
                 return ResponseBuilder::createErrorResponse($this->app, ResponseBuilder::STATUS_TYPE_ROUTE_NOT_FOUND, $e->getMessage(), $code);
             default:
                 return ResponseBuilder::createErrorResponse($this->app, ResponseBuilder::STATUS_TYPE_ERROR, $e->getMessage(), $code);
         }
     });
 }
Example #5
0
 public function boot(Application $app)
 {
     $app->error(function (Exception $e) use($app) {
         $app['logger']->addError($e->getMessage());
         return new Response($e->getMessage());
     });
 }
Example #6
0
 public function __construct(array $config = array())
 {
     parent::__construct($config);
     parent::error(function (\Exception $e, $code) {
         return parent::json(array("error" => $e->getMessage()), $code);
     });
 }
Example #7
0
 public function connect(Application $app)
 {
     $route = $app['controllers_factory'];
     $route->get('/', function (Application $app, Request $request) {
         return $app['mh.controllers.base']->index($request);
     });
     $route->post('/guest', function (Application $app, Request $request) {
         return $app['mh.controllers.guest']->find($request);
     });
     $route->get('/pay/{id}', function (Application $app, Request $request, $id) {
         return $app['mh.controllers.guest']->payment($id);
     });
     $route->post('/process/{id}', function (Application $app, Request $request, $id) {
         return $app['mh.controllers.transaction']->pay($request, $id);
     });
     $route->get('/not-found', function (Application $app) {
         return $app['mh.controllers.guest']->notFound();
     });
     $route->get('/thank-you', function (Application $app) {
         return $app['mh.controllers.guest']->thanks();
     });
     $app->error(function (\Exception $e, $code) {
         if (404 == $code) {
             return new Response('', 301, ['location' => '/']);
         }
     });
     return $route;
 }
 public function boot(\Silex\Application $app)
 {
     $app->before(function (\Symfony\Component\HttpFoundation\Request $request) use($app) {
         $routeName = $request->attributes->get('_route');
         $route = $request->getRequestUri();
         $log = $_SERVER['REMOTE_ADDR'] . ' - ';
         if ($app['session']->has('user') && defined('USERNAME_METHOD_LOGGED')) {
             $user = $app['session']->get('user');
             $method = USERNAME_METHOD_LOGGED;
             if (is_callable(array($user, $method))) {
                 $name = $user->{$method}();
                 if (!empty($name)) {
                     $log .= $name;
                 }
             }
         }
         if (!empty($routeName)) {
             $log .= ' está acessando a rota "' . $routeName . '" (' . $route . ')';
         } else {
             if (!file_exists(__WEBROOT__ . $route)) {
                 $log .= ' tentou acessar um arquivo ou rota inexistente (' . $route . ')!';
             } else {
                 $log .= ' está acessando um arquivo (' . $route . ')!';
             }
         }
         $app['monolog']->addInfo($log);
     });
     $app->error(function (\Exception $e, $code) use($app) {
         $msg = $code != 500 ? $e->getMessage() : $e->getFile() . ' na linha ' . $e->getLine() . ': ' . $e->getMessage();
         $app['monolog']->addError('cod: ' . $code . ' => ' . $msg);
     });
 }
 public function boot(Application $app)
 {
     $app->before(function (Request $request) use($app) {
         $app['monolog']->addInfo('> ' . $request->getMethod() . ' ' . $request->getRequestUri());
     });
     /*
      * Priority -4 is used to come after those from SecurityServiceProvider (0)
      * but before the error handlers added with Silex\Application::error (defaults to -8)
      */
     $app->error(function (\Exception $e) use($app) {
         $message = sprintf('%s: %s (uncaught exception) at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine());
         if ($e instanceof HttpExceptionInterface && $e->getStatusCode() < 500) {
             $app['monolog']->addError($message, array('exception' => $e));
         } else {
             $app['monolog']->addCritical($message, array('exception' => $e));
         }
     }, -4);
     $app->after(function (Request $request, Response $response) use($app) {
         if ($response instanceof RedirectResponse) {
             $app['monolog']->addInfo('< ' . $response->getStatusCode() . ' ' . $response->getTargetUrl());
         } else {
             $app['monolog']->addInfo('< ' . $response->getStatusCode());
         }
     });
 }
Example #10
0
 public function testRegisterAndRender()
 {
     $app = new Application();
     $app->register(new MonologExtension(), array('monolog.class_path' => __DIR__ . '/../../../../vendor/monolog/src'));
     $app['monolog.handler'] = $app->share(function () use($app) {
         return new TestHandler($app['monolog.level']);
     });
     $app->get('/log', function () use($app) {
         $app['monolog']->addDebug('logging a message');
     });
     $app->get('/error', function () {
         throw new \RuntimeException('very bad error');
     });
     $app->error(function (\Exception $e) {
         return 'error handled';
     });
     $this->assertFalse($app['monolog.handler']->hasDebugRecords());
     $this->assertFalse($app['monolog.handler']->hasErrorRecords());
     $request = Request::create('/log');
     $app->handle($request);
     $request = Request::create('/error');
     $app->handle($request);
     $this->assertTrue($app['monolog.handler']->hasDebugRecords());
     $this->assertTrue($app['monolog.handler']->hasErrorRecords());
 }
 /**
  * Bootstrap Silex Application for tests
  * @method createApplication
  * @return $app              Silex\Application
  */
 public function createApplication()
 {
     $app = new Application(['dev' => true]);
     // errors
     error_reporting(E_ALL ^ E_STRICT);
     $app->error(function (Exception $e, $code) use($app) {
         return $app->json(['error' => $e->getMessage(), 'type' => get_class($e)], $code);
     });
     // database
     $app->register(new DoctrineServiceProvider(), ['db.options' => ['driver' => 'pdo_sqlite', 'path' => __DIR__ . '/tests.db', 'charset' => 'UTF8']]);
     // jwt (json-web-token)
     $app['security.jwt'] = ['secret_key' => 'omg-so-secret-test-!', 'life_time' => 2592000, 'algorithm' => ['HS256'], 'options' => ['header_name' => 'X-Access-Token', 'username_claim' => 'email']];
     $app->register(new SecurityServiceProvider());
     $app->register(new SecurityJWTServiceProvider());
     // mailer
     $app->register(new SwiftmailerServiceProvider(), ['swiftmailer.options' => ['host' => '127.0.0.1', 'port' => '1025']]);
     // twig
     $app->register(new TwigServiceProvider(), ['twig.path' => __DIR__ . '/../templates']);
     $app->register(new UrlGeneratorServiceProvider());
     // simple-user-jwt
     $app['user.jwt.options'] = ['invite' => ['enabled' => true], 'forget' => ['enabled' => true], 'mailer' => ['enabled' => true, 'from' => ['email' => '*****@*****.**', 'name' => 'Test']]];
     $app->register(new UserProvider());
     // roles
     $app['security.role_hierarchy'] = ['ROLE_INVITED' => ['ROLE_USER'], 'ROLE_REGISTERED' => ['ROLE_INVITED', 'ROLE_ALLOW_INVITE'], 'ROLE_ADMIN' => ['ROLE_REGISTERED']];
     // needed to parse user at each request
     $app['security.firewalls'] = ['login' => ['pattern' => 'register|login|forget|reset', 'anonymous' => true], 'secured' => ['pattern' => '.*$', 'users' => $app->share(function () use($app) {
         return $app['user.manager'];
     }), 'jwt' => ['use_forward' => true, 'require_previous_session' => false, 'stateless' => true]]];
     // controller
     $app->mount('/', new UserProvider());
     return $app;
 }
Example #12
0
 public function register(Application $app)
 {
     $app['monolog'] = $app->share(function () use($app) {
         $log = new Logger(isset($app['monolog.name']) ? $app['monolog.name'] : 'myapp');
         $app['monolog.configure']($log);
         return $log;
     });
     $app['monolog.configure'] = $app->protect(function ($log) use($app) {
         $log->pushHandler($app['monolog.handler']);
     });
     $app['monolog.handler'] = function () use($app) {
         return new StreamHandler($app['monolog.logfile'], $app['monolog.level']);
     };
     if (!isset($app['monolog.level'])) {
         $app['monolog.level'] = function () {
             return Logger::DEBUG;
         };
     }
     if (isset($app['monolog.class_path'])) {
         $app['autoloader']->registerNamespace('Monolog', $app['monolog.class_path']);
     }
     $app->before(function (Request $request) use($app) {
         $app['monolog']->addInfo('> ' . $request->getMethod() . ' ' . $request->getRequestUri());
     });
     $app->error(function (\Exception $e) use($app) {
         $app['monolog']->addError($e->getMessage());
     });
     $app->after(function (Request $request, Response $response) use($app) {
         $app['monolog']->addInfo('< ' . $response->getStatusCode());
     });
 }
Example #13
0
 public function connect(Application $app)
 {
     # bind app to his controller
     $this->app = $app;
     # bind errro handler
     $app->error(array($this, 'handleError'));
 }
Example #14
0
 protected function setJsonErrorHandler()
 {
     /** @noinspection PhpUnusedParameterInspection */
     $this->app->error(function (\Exception $e, $code) {
         $message = 'Threw ' . get_class($e) . ': ' . $e->getMessage();
         return new JsonResponse(['error' => $message]);
     });
 }
Example #15
0
 public function boot(Application $app)
 {
     $app->error(function (Exception $e) use($app) {
         $app['logger']->addError($e->getMessage());
         $status = $e->getCode() > 99 ? $e->getCode() : 500;
         return new Response($e->getMessage(), $status);
     });
 }
 /**
  * @inheritdoc
  */
 public function register(Application $app)
 {
     $app->error(function (ValidationException $e) {
         $problem = $this->createNewApiProblem($e);
         $problem['validation_messages'] = $e->getErrors();
         return new ApiProblemJsonResponse($problem);
     });
     $app->error(function (DataValidationException $e) {
         $problem = new ApiProblem('Invalid payload.');
         $problem['validation_messages'] = $e->getValidationMessages();
         return new ApiProblemJsonResponse($problem);
     });
     $app->error(function (\Exception $e) {
         $problem = $this->createNewApiProblem($e);
         return new ApiProblemJsonResponse($problem);
     });
 }
 public function connect(Application $app)
 {
     $controllers = $app['controllers_factory'];
     $controllers->get('/login', 'login.controller:loginAction')->bind('sms.login');
     $controllers->post('/login', 'login.controller:verifyAction');
     // Convert Twilio exception to Auth exception
     $app->error(function (\Services_Twilio_RestException $e) use($app) {
         $app['monolog']->addDebug('Converting Twilio Exception: ' . $e->getMessage());
         $app['session']->set(Security::AUTHENTICATION_ERROR, new BadCredentialsException('Invalid phone number'));
         return $app->redirect($app['url_generator']->generate('sms.login'));
     });
     // Store Auth exception and go back to login form
     $app->error(function (AuthenticationException $e) use($app) {
         $app['session']->set(Security::AUTHENTICATION_ERROR, $e);
         return $app->redirect($app['url_generator']->generate('sms.login'));
     });
     return $controllers;
 }
 public function boot(Application $app)
 {
     $app->before($app['monolog.boot.before']);
     /*
      * Priority -4 is used to come after those from SecurityServiceProvider (0)
      * but before the error handlers added with Silex\Application::error (defaults to -8)
      */
     $app->error($app['monolog.boot.error'], -4);
     $app->after($app['monolog.boot.after']);
 }
 public function boot(Application $app)
 {
     // Error Handling
     $schema = $app["url_generator"]->generate("schema", array("type" => "error"));
     $app["twig.loader"]->addLoader(new Twig_Loader_Filesystem(__DIR__ . "/templates"));
     $app->before(new AddSchema($schema, "error"));
     $app->error(function (\Exception $e, $code) use($app) {
         $app["json-schema.describedBy"] = $app["url_generator"]->generate("schema", array("type" => "error"));
     }, self::ERROR_HANDLER_PRIORITY);
 }
 public function register(Application $app)
 {
     ErrorHandler::register();
     ExceptionHandler::register($app['debug']);
     $app->error(function (\Exception $exception, $code) use($app) {
         if (!$app['debug'] || $code === 404) {
             // 404.html, or 40x.html, or 4xx.html, or error.html
             $templates = array('errors/' . $code . '.html.twig', 'errors/' . substr($code, 0, 2) . 'x.html.twig', 'errors/' . substr($code, 0, 1) . 'xx.html.twig', 'errors/' . 'default.html.twig');
             return new Response($app['twig']->resolveTemplate($templates)->render(array('code' => $code)), $code);
         }
     });
 }
 public function connect(App $app)
 {
     $this->app = $app;
     $app->error([$this, 'error']);
     $controllers = $app['controllers_factory'];
     $controllers->get('/', [$this, 'homepage'])->bind('homepage');
     $controllers->get('/login', [$this, 'login'])->bind('login');
     $controllers->get('/doctrine', [$this, 'doctrine'])->bind('doctrine');
     $controllers->match('/form', [$this, 'form'])->bind('form');
     $controllers->get('/cache', [$this, 'cache'])->bind('cache');
     return $controllers;
 }
Example #22
0
 public function boot(Application $app)
 {
     $app->before(function (Request $request) use($app) {
         $app['monolog']->addInfo('> ' . $request->getMethod() . ' ' . $request->getRequestUri());
     });
     $app->error(function (\Exception $e) use($app) {
         $app['monolog']->addError($e->getMessage());
     }, 255);
     $app->after(function (Request $request, Response $response) use($app) {
         $app['monolog']->addInfo('< ' . $response->getStatusCode());
     });
 }
 /**
  * Register error handlers on the application.
  * Has entries for both Synapse's and Symfony's 501 exceptions so that both return the same response.
  *
  * @param Application $app
  */
 public function register(Application $app)
 {
     $getCorsResponse = function ($message, $statusCode) use($app) {
         $response = new JsonResponse(['message' => $message], $statusCode);
         $app['cors']($app['request'], $response);
         return $response;
     };
     $app->error(function (MethodNotImplementedException $e, $code) use($getCorsResponse) {
         return $getCorsResponse(self::METHOD_NOT_IMPLEMENTED_MESSAGE, 501);
     });
     $app->error(function (MethodNotAllowedHttpException $e, $code) use($getCorsResponse) {
         return $getCorsResponse(self::METHOD_NOT_IMPLEMENTED_MESSAGE, 501);
     });
     $app->error(function (NotFoundHttpException $e, $code) use($getCorsResponse) {
         return $getCorsResponse('Not found', 404);
     });
     $app->error(function (AccessDeniedHttpException $e, $code) use($getCorsResponse) {
         return $getCorsResponse('Access denied', 403);
     });
     $app->error(function (BadRequestException $e, $code) use($getCorsResponse) {
         return $getCorsResponse('Could not parse json body', 400);
     });
     $app->error(function (Exception $e, $code) use($getCorsResponse, $app) {
         $app['log']->addError($e->getMessage(), ['exception' => $e]);
         $debug = $app['config']->load('init')['debug'];
         if ($debug) {
             $responseBody = ['error' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => $e->getTrace()];
             $response = new JsonResponse($responseBody, 500);
         } else {
             $response = $getCorsResponse(self::SERVER_ERROR_MESSAGE, 500);
         }
         $app['cors']($app['request'], $response);
         return $response;
     });
 }
 /**
  * {@inheritDoc}
  */
 public function register(SilexApplication $app)
 {
     $app['payum.api.controller.root'] = $app->share(function () {
         return new RootController();
     });
     $app['payum.api.controller.payment'] = $app->share(function () use($app) {
         return new PaymentController($app['payum.security.token_factory'], $app['payum.security.http_request_verifier'], $app['payum'], $app['api.view.order_to_json_converter'], $app['form.factory'], $app['api.view.form_to_json_converter']);
     });
     $app['payum.api.controller.gateway'] = $app->share(function () use($app) {
         return new GatewayController($app['form.factory'], $app['url_generator'], $app['api.view.form_to_json_converter'], $app['payum.gateway_config_storage'], $app['api.view.gateway_config_to_json_converter']);
     });
     $app['payum.api.controller.gateway_meta'] = $app->share(function () use($app) {
         return new GatewayMetaController($app['form.factory'], $app['api.view.form_to_json_converter'], $app['payum']);
     });
     $app->get('/', 'payum.api.controller.root:rootAction')->bind('api_root');
     $app->get('/payments/meta', 'payum.api.controller.payment:metaAction')->bind('payment_meta');
     $app->get('/payments/{payum_token}', 'payum.api.controller.payment:getAction')->bind('payment_get');
     $app->put('/payments/{payum_token}', 'payum.api.controller.payment:updateAction')->bind('payment_update');
     $app->delete('/payments/{payum_token}', 'payum.api.controller.payment:deleteAction')->bind('payment_delete');
     $app->post('/payments', 'payum.api.controller.payment:createAction')->bind('payment_create');
     $app->get('/payments', 'payum.api.controller.payment:allAction')->bind('payment_all');
     $app->get('/gateways/meta', 'payum.api.controller.gateway_meta:getAllAction')->bind('payment_factory_get_all');
     $app->get('/gateways', 'payum.api.controller.gateway:allAction')->bind('gateway_all');
     $app->get('/gateways/{name}', 'payum.api.controller.gateway:getAction')->bind('gateway_get');
     $app->delete('/gateways/{name}', 'payum.api.controller.gateway:deleteAction')->bind('gateway_delete');
     $app->post('/gateways', 'payum.api.controller.gateway:createAction')->bind('gateway_create');
     $app->before(function (Request $request, Application $app) {
         if (in_array($request->getMethod(), array('GET', 'OPTIONS', 'DELETE'))) {
             return;
         }
         if ('json' !== $request->getContentType()) {
             throw new BadRequestHttpException('The request content type is invalid. It must be application/json');
         }
         $decodedContent = json_decode($request->getContent(), true);
         if (null === $decodedContent) {
             throw new BadRequestHttpException('The request content is not valid json.');
         }
         $request->attributes->set('content', $decodedContent);
     });
     $app->after(function (Request $request, Response $response) use($app) {
         if ($response instanceof JsonResponse && $app['debug']) {
             $response->setEncodingOptions($response->getEncodingOptions() | JSON_PRETTY_PRINT);
         }
     });
     $app->after($app["cors"]);
     $app->error(function (\Exception $e, $code) use($app) {
         if ('json' !== $app['request']->getContentType()) {
             return;
         }
         return new JsonResponse(array('exception' => get_class($e), 'message' => $e->getMessage(), 'code' => $e->getCode(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'stackTrace' => $e->getTraceAsString()));
     }, $priority = -100);
 }
 /**
  * Registers services on the given app.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param Application $app An Application instance
  */
 public function register(Application $app)
 {
     $app->error(function (\Exception $e, $code) use($app) {
         if ($app['debug']) {
             return;
             // exibir erro no ambiente desenvolvimento.
         }
         // Exibir pagina de erro personalizada.
         // busca pagina de erro pelo código 404.html, 40x.html, 4xx.html ou error.html
         $templates = array('errors/' . $code . '.html', 'errors/' . substr($code, 0, 2) . 'x.html', 'errors/' . substr($code, 0, 1) . 'xx.html', 'errors/error.html');
         return new Response($app['twig']->resolveTemplate($templates)->render(array('code' => $code, 'error' => $e->getMessage())), $code);
     });
 }
 /**
  * {@inheritdoc}
  */
 public function register(Application $app)
 {
     // handling CORS preflight request
     $app->before(function (Request $request) {
         if ($request->getMethod() === 'OPTIONS') {
             $response = new Response();
             $response->headers->set('Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE,OPTIONS');
             $response->headers->set('Access-Control-Allow-Headers', 'Content-Type');
             $response->headers->set('Access-Control-Allow-Origin', '*');
             $response->setStatusCode(200);
             return $response;
         }
     }, $app::EARLY_EVENT);
     $app->before(function (Request $request) {
         if (0 === strpos($request->headers->get('Content-Type'), 'application/json')) {
             $data = json_decode($request->getContent(), true);
             $request->request->replace(is_array($data) ? $data : []);
         }
     });
     // CORS domain
     $app->after(function (Request $request, Response $response) {
         $response->headers->set('Access-Control-Allow-Origin', '*');
         return $response;
     });
     // Returns the status code in the response body
     $app->after(function (Request $request, Response $response) {
         $status = $response->getStatusCode();
         // Errors
         if ($status >= 400 && $response instanceof JsonResponse) {
             $data = json_decode($response->getContent(), true);
             if (!is_array($data)) {
                 $data = [];
             }
             $response->setData(array_merge($data, ['status' => $status]));
         }
         return $response;
     });
     // Converts HTTP exception to response
     $app->error(function (\Exception $e) {
         $response = null;
         switch (true) {
             case $e instanceof NotFoundHttpException:
             case $e instanceof BadRequestHttpException:
                 $response = new JsonResponse(['message' => $e->getMessage()], $e->getStatusCode(), $e->getHeaders());
                 break;
             default:
         }
         return $response;
     });
 }
 public function boot(Application $app)
 {
     // BC: to be removed before 1.0
     if (isset($app['monolog.class_path'])) {
         throw new \RuntimeException('You have provided the monolog.class_path parameter. The autoloader has been removed from Silex. It is recommended that you use Composer to manage your dependencies and handle your autoloading. If you are already using Composer, you can remove the parameter. See http://getcomposer.org for more information.');
     }
     $app->before(function (Request $request) use($app) {
         $app['monolog']->addInfo('> ' . $request->getMethod() . ' ' . $request->getRequestUri());
     });
     $app->error(function (\Exception $e) use($app) {
         $app['monolog']->addError($e->getMessage());
     }, 255);
     $app->after(function (Request $request, Response $response) use($app) {
         $app['monolog']->addInfo('< ' . $response->getStatusCode());
     });
 }
 public function boot(Application $app)
 {
     $app->before(function (Request $request) use($app) {
         $app['monolog']->addInfo('> ' . $request->getMethod() . ' ' . $request->getRequestUri());
     });
     $app->error(function (\Exception $e) use($app) {
         $message = sprintf('%s: %s (uncaught exception) at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine());
         if ($e instanceof HttpExceptionInterface && $e->getStatusCode() < 500) {
             $app['monolog']->addError($message);
         } else {
             $app['monolog']->addCritical($message);
         }
     }, 255);
     $app->after(function (Request $request, Response $response) use($app) {
         $app['monolog']->addInfo('< ' . $response->getStatusCode());
     });
 }
 public function testCallbacksAsServices()
 {
     $app = new Application();
     $app['service'] = $app->share(function () {
         return new self();
     });
     $app->before('service:beforeApp');
     $app->after('service:afterApp');
     $app->finish('service:finishApp');
     $app->error('service:error');
     $app->on('kernel.request', 'service:onRequest');
     $app->match('/', 'service:controller')->convert('foo', 'service:convert')->before('service:before')->after('service:after');
     $request = Request::create('/');
     $response = $app->handle($request);
     $app->terminate($request, $response);
     $this->assertEquals(array('CONVERT', 'BEFORE APP', 'ON REQUEST', 'BEFORE', 'ERROR', 'AFTER', 'AFTER APP', 'FINISH APP'), $app['service']->called);
 }
Example #30
0
 public function connect(Application $app)
 {
     $controllers = $app['controllers_factory'];
     // *******
     // ** Signin member
     // *******
     $app->error(function (\Exception $e, $code) use($app) {
         $page = 'default';
         switch ($code) {
             default:
                 break;
         }
         $app['session']->getFlashBag()->add('error', $e->getMessage());
         return new Response($app['twig']->render('error/' . $page . '.html.twig'), $code);
     });
     // *******
     return $controllers;
 }