public function register(SilexApplication $app) { $app['manipulator.task'] = $app->share(function (SilexApplication $app) { return new TaskManipulator($app['orm.em'], $app['translator'], $app['task-manager.notifier']); }); $app['manipulator.user'] = $app->share(function ($app) { return new UserManipulator($app['model.user-manager'], $app['auth.password-encoder'], $app['geonames.connector'], $app['repo.users'], $app['random.low'], $app['dispatcher']); }); $app['manipulator.token'] = $app->share(function ($app) { return new TokenManipulator($app['orm.em'], $app['random.medium'], $app['repo.tokens'], $app['tmp.download.path']); }); $app['manipulator.preset'] = $app->share(function ($app) { return new PresetManipulator($app['orm.em'], $app['repo.presets']); }); $app['manipulator.acl'] = $app->share(function ($app) { return new ACLManipulator($app['acl'], $app->getApplicationBox()); }); $app['model.user-manager'] = $app->share(function ($app) { return new UserManager($app['orm.em'], $app->getApplicationBox()->get_connection()); }); $app['manipulator.registration'] = $app->share(function ($app) { return new RegistrationManipulator($app, $app['orm.em'], $app['acl'], $app->getApplicationBox(), $app['repo.registrations']); }); $app['manipulator.api-application'] = $app->share(function ($app) { return new ApiApplicationManipulator($app['orm.em'], $app['repo.api-applications'], $app['random.medium']); }); $app['manipulator.api-account'] = $app->share(function ($app) { return new ApiAccountManipulator($app['orm.em']); }); $app['manipulator.api-oauth-code'] = $app->share(function ($app) { return new ApiOauthCodeManipulator($app['orm.em'], $app['repo.api-oauth-codes'], $app['random.medium']); }); $app['manipulator.api-oauth-token'] = $app->share(function ($app) { return new ApiOauthTokenManipulator($app['orm.em'], $app['repo.api-oauth-tokens'], $app['random.medium']); }); $app['manipulator.api-oauth-refresh-token'] = $app->share(function ($app) { return new ApiOauthRefreshTokenManipulator($app['orm.em'], $app['repo.api-oauth-refresh-tokens'], $app['random.medium']); }); $app['manipulator.api-log'] = $app->share(function ($app) { return new ApiLogManipulator($app['orm.em'], $app['repo.api-logs']); }); $app['manipulator.webhook-event'] = $app->share(function ($app) { return new WebhookEventManipulator($app['orm.em'], $app['repo.webhook-event']); }); $app['manipulator.webhook-delivery'] = $app->share(function ($app) { return new WebhookEventDeliveryManipulator($app['orm.em'], $app['repo.webhook-delivery']); }); }
public function register(SilexApplication $app) { $app['phraseanet.configuration.yaml-parser'] = $app->share(function (SilexApplication $app) { return new Yaml(); }); $app['phraseanet.configuration.compiler'] = $app->share(function (SilexApplication $app) { return new Compiler(); }); $app['phraseanet.configuration.config-path'] = function (SilexApplication $app) { return sprintf('%s/config/configuration.yml', $app['root.path']); }; $app['phraseanet.configuration.config-compiled-path'] = function (SilexApplication $app) { return sprintf('%s/config/configuration-compiled.php', $app['root.path']); }; $app['configuration.store'] = $app->share(function (SilexApplication $app) { return new HostConfiguration(new Configuration($app['phraseanet.configuration.yaml-parser'], $app['phraseanet.configuration.compiler'], $app['phraseanet.configuration.config-path'], $app['phraseanet.configuration.config-compiled-path'], $app['debug'])); }); $app['registry.manipulator'] = $app->share(function (SilexApplication $app) { return new RegistryManipulator($app['form.factory'], $app['translator'], $app['locales.available']); }); $app['conf'] = $app->share(function (SilexApplication $app) { return new PropertyAccess($app['configuration.store']); }); // Maintaining BC until 3.10 $app['phraseanet.configuration'] = $app->share(function (SilexApplication $app) { return $app['configuration.store']; }); $app['settings'] = $app->share(function (SilexApplication $app) { return new DisplaySettingService($app['conf']); }); $app['conf.restrictions'] = $app->share(function (SilexApplication $app) { return new AccessRestriction($app['cache'], $app['conf'], $app->getApplicationBox(), $app['monolog']); }); }
public function register(Application $app) { if (!$app instanceof PhraseaApplication) { throw new \LogicException('Expects $app to be an instance of Phraseanet application'); } $app['repo.users'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:User'); }); $app['repo.auth-failures'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:AuthFailure'); }); $app['repo.sessions'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:Session'); }); $app['repo.tasks'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:Task'); }); $app['repo.registrations'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:Registration'); }); $app['repo.baskets'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:Basket'); }); $app['repo.basket-elements'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:BasketElement'); }); $app['repo.validation-participants'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:ValidationParticipant'); }); $app['repo.story-wz'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:StoryWZ'); }); $app['repo.orders'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:Order'); }); $app['repo.order-elements'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:OrderElement'); }); $app['repo.feeds'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:Feed'); }); $app['repo.feed-entries'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:FeedEntry'); }); $app['repo.feed-items'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:FeedItem'); }); $app['repo.feed-publishers'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:FeedPublisher'); }); $app['repo.feed-tokens'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:FeedToken'); }); $app['repo.aggregate-tokens'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:AggregateToken'); }); $app['repo.usr-lists'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:UsrList'); }); $app['repo.usr-list-owners'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:UsrListOwner'); }); $app['repo.usr-list-entries'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:UsrListEntry'); }); $app['repo.lazaret-files'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:LazaretFile'); }); $app['repo.usr-auth-providers'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:UsrAuthProvider'); }); $app['repo.ftp-exports'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:FtpExport'); }); $app['repo.user-queries'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:UserQuery'); }); $app['repo.tokens'] = $app->share(function ($app) { return $app['orm.em']->getRepository('Phraseanet:Token'); }); $app['repo.presets'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:Preset'); }); $app['repo.api-accounts'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:ApiAccount'); }); $app['repo.api-logs'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:ApiLog'); }); $app['repo.api-applications'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:ApiApplication'); }); $app['repo.api-oauth-codes'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:ApiOauthCode'); }); $app['repo.api-oauth-tokens'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:ApiOauthToken'); }); $app['repo.api-oauth-refresh-tokens'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:ApiOauthRefreshToken'); }); $app['repo.webhook-event'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:WebhookEvent'); }); $app['repo.webhook-delivery'] = $app->share(function (PhraseaApplication $app) { return $app['orm.em']->getRepository('Phraseanet:WebhookEventDelivery'); }); $app['repo.databoxes'] = $app->share(function (PhraseaApplication $app) { $factory = new DataboxFactory($app); $appbox = $app->getApplicationBox(); $repository = new DbalDataboxRepository($appbox->get_connection(), $factory); return new CachingDataboxRepositoryDecorator($repository, $app['cache'], $appbox->get_cache_key($appbox::CACHE_LIST_BASES), $factory); }); $app['repo.fields.factory'] = $app->protect(function (\databox $databox) use($app) { return new DbalDataboxFieldRepository($databox->get_connection(), new DataboxFieldFactory($app, $databox)); }); $app['repo.records.factory'] = $app->protect(function (\databox $databox) use($app) { return new LegacyRecordRepository($app, $databox); }); }
public function register(Application $app) { $app['authentication'] = $app->share(function (Application $app) { return new Authenticator($app, $app['browser'], $app['session'], $app['orm.em']); }); $app['authentication.persistent-manager'] = $app->share(function (Application $app) { return new CookieManager($app['auth.password-encoder'], $app['repo.sessions'], $app['browser']); }); $app['authentication.suggestion-finder'] = $app->share(function (Application $app) { return new SuggestionFinder($app['repo.users']); }); $app['authentication.providers.factory'] = $app->share(function (Application $app) { return new ProviderFactory($app['url_generator'], $app['session']); }); $app['authentication.providers.account-creator'] = $app->share(function (Application $app) { $authConf = $app['conf']->get('authentication'); $templates = array_filter(array_map(function ($templateId) use($app) { try { if (is_int($templateId) || ctype_digit($templateId)) { return $app['repo.users']->find($templateId); } if (false !== $templateId) { return $app['repo.users']->find($templateId); } } catch (\Exception $e) { } }, $authConf['auto-create']['templates'])); $enabled = $app['conf']->get(['registry', 'registration', 'auto-register-enabled']) && $app['registration.manager']->isRegistrationEnabled(); return new AccountCreator($app['random.medium'], $app->getApplicationBox(), $enabled, $templates); }); $app['authentication.providers'] = $app->share(function (Application $app) { $providers = new ProvidersCollection(); $authConf = $app['conf']->get('authentication'); foreach ($authConf['providers'] as $providerId => $data) { if (isset($data['enabled']) && false === $data['enabled']) { continue; } $providers->register($app['authentication.providers.factory']->build($providerId, $data['options'])); } return $providers; }); $app['authentication.manager'] = $app->share(function (Application $app) { return new Manager($app['authentication'], $app['authentication.providers']); }); $app['authentication.recovery_service'] = $app->share(function (Application $app) { return new RecoveryService($app, $app['notification.deliverer'], $app['manipulator.token'], $app['repo.tokens'], $app['manipulator.user'], $app['repo.users'], $app['url_generator']); }); $app['authentication.registration_service'] = $app->share(function (Application $app) { return new RegistrationService($app, $app['phraseanet.appbox'], $app['acl'], $app['conf'], $app['orm.em'], $app['dispatcher'], $app['authentication.providers'], $app['repo.usr-auth-providers'], $app['repo.users'], $app['manipulator.user'], $app['manipulator.token'], $app['repo.tokens'], $app['manipulator.registration'], $app['registration.manager']); }); $app['auth.password-encoder'] = $app->share(function (Application $app) { return new PasswordEncoder($app['conf']->get(['main', 'key'])); }); $app['auth.old-password-encoder'] = $app->share(function (Application $app) { return new OldPasswordEncoder(); }); $app['auth.native.failure-manager'] = $app->share(function (Application $app) { $authConf = $app['conf']->get(['authentication', 'captcha']); return new FailureManager($app['repo.auth-failures'], $app['orm.em'], $app['recaptcha'], isset($authConf['trials-before-display']) ? $authConf['trials-before-display'] : 9); }); $app['auth.password-checker'] = $app->share(function (Application $app) { return new NativeAuthentication($app['auth.password-encoder'], $app['auth.old-password-encoder'], $app['manipulator.user'], $app['repo.users']); }); $app['auth.native'] = $app->share(function (Application $app) { $authConf = $app['conf']->get('authentication'); if ($authConf['captcha']['enabled']) { return new FailureHandledNativeAuthentication($app['auth.password-checker'], $app['auth.native.failure-manager']); } else { return $app['auth.password-checker']; } }); }
public function register(Application $app) { $app['controller.datafiles'] = $app->share(function (PhraseaApplication $app) { return (new DatafileController($app, $app->getApplicationBox(), $app['acl'], $app->getAuthenticator()))->setDataboxLoggerLocator($app['phraseanet.logger'])->setDelivererLocator(new LazyLocator($app, 'phraseanet.file-serve')); }); }