当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::after方法代码示例

本文整理汇总了PHP中Alchemy\Phrasea\Application::after方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::after方法的具体用法?PHP Application::after怎么用?PHP Application::after使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Alchemy\Phrasea\Application的用法示例。


在下文中一共展示了Application::after方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

         $app->abort(406);
     }
     // set request format according to negotiated content or override format with JSONP if callback parameter is defined
     if (trim($request->get('callback')) !== '') {
         $request->setRequestFormat(Result::FORMAT_JSONP);
     } else {
         $request->setRequestFormat($request->getFormat($format->getValue()));
     }
     // tells whether asked format is extended or not
     $request->attributes->set('_extended', in_array($request->getRequestFormat(Result::FORMAT_JSON), array(Result::FORMAT_JSON_EXTENDED, Result::FORMAT_YAML_EXTENDED, Result::FORMAT_JSONP_EXTENDED)));
 }, PhraseaApplication::EARLY_EVENT);
 $app->after(function (Request $request, Response $response) use($app) {
     if ($request->getRequestFormat(Result::FORMAT_JSON) === Result::FORMAT_JSONP && !$response->isOk() && !$response->isServerError()) {
         $response->setStatusCode(200);
     }
     // set response content type
     if (!$response->headers->get('Content-Type')) {
         $response->headers->set('Content-Type', $request->getMimeType($request->getRequestFormat(Result::FORMAT_JSON)));
     }
 });
 $app->get('/api/', function (Request $request, SilexApplication $app) {
     return Result::create($request, ['name' => $app['conf']->get(['registry', 'general', 'title']), 'type' => 'phraseanet', 'description' => $app['conf']->get(['registry', 'general', 'description']), 'documentation' => 'https://docs.phraseanet.com/Devel', 'versions' => ['1' => ['number' => V1::VERSION, 'uri' => '/api/v1/', 'authenticationProtocol' => 'OAuth2', 'authenticationVersion' => 'draft#v9', 'authenticationEndPoints' => ['authorization_token' => '/api/oauthv2/authorize', 'access_token' => '/api/oauthv2/token']]]])->createResponse();
 });
 $app->mount('/api/oauthv2', new Oauth2());
 $app->mount('/api/v1', new V1());
 $app['dispatcher'] = $app->share($app->extend('dispatcher', function ($dispatcher, PhraseaApplication $app) {
     $dispatcher->addSubscriber(new ApiOauth2ErrorsSubscriber($app['phraseanet.exception_handler'], $app['translator']));
     return $dispatcher;
 }));
 $app->after(function (Request $request, Response $response) use($app) {
     $app['dispatcher']->dispatch(PhraseaEvents::API_RESULT, new ApiResultEvent($request, $response));
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:31,代码来源:Api.php


注:本文中的Alchemy\Phrasea\Application::after方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。