public function get_feed_entry(Application $app, Request $request, $entry_id) { $user = $app['authentication']->getUser(); $entry = $app['repo.feed-entries']->find($entry_id); $collection = $entry->getFeed()->getCollection($app); if (null !== $collection && !$app['acl']->get($user)->has_access_to_base($collection->get_base_id())) { return Result::createError($request, 403, 'You have not access to the parent feed')->createResponse(); } return Result::create($request, ['entry' => $this->list_publication_entry($app, $entry)])->createResponse(); }
$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)); }); $app['dispatcher']->addSubscriber(new ApiCorsSubscriber($app)); return $app; }, isset($environment) ? $environment : PhraseaApplication::ENV_PROD);
public function createCollectionRequests(Request $request) { $service = $this->getRegistrationService(); $user = $this->getAuthenticatedUser(); $data = json_decode($request->getContent(false), true); $service->createCollectionRequests($user, $data); return Result::create($request, $this->listUserDemands($user))->createResponse(); }