/**
  * @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;
 }
 public function connect(Application $app)
 {
     /** @var ControllerCollection $controllers */
     $controllers = $app['controllers_factory'];
     $offerServices = ['event' => 'event_editor_with_label_memory', 'place' => 'place_editing_service_with_label_memory'];
     foreach ($offerServices as $offerType => $serviceName) {
         $controllerName = "{$offerType}_offer_controller";
         $patchControllerName = "patch_{$offerType}_controller";
         $app[$controllerName] = $app->share(function (Application $app) use($serviceName) {
             return new EditOfferRestController($app[$serviceName], new LabelJSONDeserializer(), new TitleJSONDeserializer(), new DescriptionJSONDeserializer(), new PriceInfoJSONDeserializer());
         });
         $app[$patchControllerName] = $app->share(function (Application $app) use($offerType) {
             return new PatchOfferRestController(OfferType::fromCaseInsensitiveValue($offerType), $app['event_command_bus']);
         });
         $controllers->post("{$offerType}/{cdbid}/labels", "{$controllerName}:addLabel");
         $controllers->delete("{$offerType}/{cdbid}/labels/{label}", "{$controllerName}:removeLabel");
         $controllers->post("{$offerType}/{cdbid}/{lang}/title", "{$controllerName}:translateTitle");
         $controllers->post("{$offerType}/{cdbid}/{lang}/description", "{$controllerName}:translateDescription");
         $controllers->put("{$offerType}/{cdbid}/priceInfo", "{$controllerName}:updatePriceInfo");
         $controllers->patch("{$offerType}/{cdbid}", "{$patchControllerName}:handle");
     }
     return $controllers;
 }