/** * @param Application $app */ public function register(Application $app) { $app['offer_reading_service'] = $app->share(function (Application $app) { return (new LocalOfferReadingService($app['iri_offer_identifier_factory']))->withDocumentRepository(OfferType::EVENT(), $app['event_jsonld_repository'])->withDocumentRepository(OfferType::PLACE(), $app['place_jsonld_repository']); }); $app['external_offer_editing_service'] = $app->share(function (Application $app) { return new DefaultExternalOfferEditingService($app['http.guzzle'], $app['http.guzzle_psr7_factory'], $app['http.jwt_request_authorizer']); }); $app['iri_offer_identifier_factory'] = $app->share(function (Application $app) { return new IriOfferIdentifierFactory($app['config']['offer_url_regex']); }); }
/** * @inheritdoc */ public function connect(Application $app) { $app['variations_read_controller'] = $app->share(function (Application $app) { return new ReadVariationsRestController($app['variations.jsonld_repository'], $app['variations.search'], $app['url_generator']); }); $app['variations_write_controller'] = $app->share(function (Application $app) { $urlValidator = (new DefaultUrlValidator($app['iri_offer_identifier_factory']))->withEntityService(OfferType::EVENT(), $app['event_service'])->withEntityService(OfferType::PLACE(), $app['place_service']); $deserializer = new CreateOfferVariationJSONDeserializer(); $deserializer->addUrlValidator($urlValidator); return new CommandDeserializerController($deserializer, $app['event_command_bus']); }); $app['variations_edit_controller'] = $app->share(function (Application $app) { return new EditVariationsRestController($app['variations.jsonld_repository'], $app['event_command_bus']); }); /* @var ControllerCollection $controllers */ $controllers = $app['controllers_factory']; $controllers->get('/', 'variations_read_controller:search')->bind('variations'); $controllers->post('/', 'variations_write_controller:handle'); $controllers->get('/{id}', 'variations_read_controller:get'); $controllers->patch('/{id}', 'variations_edit_controller:edit'); $controllers->delete('/{id}', 'variations_edit_controller:delete'); return $controllers; }