If no IoC container is registered, we raise an exception.
public getContainer ( ) : Interop\Container\ContainerInterface | ||
return | Interop\Container\ContainerInterface |
public function up(Application $app, EntityManager $em) { $accountService = $app->getContainer()->get(AccountService::class); /** @var AccountService $accountService */ $appAccessAccountService = $app->getContainer()->get(AccountAppAccessService::class); /** @var AccountAppAccessService $account */ $all = $accountService->createAccount('*****@*****.**', self::ACCOUNT_PASSWORD); $admin = $accountService->createAccount('*****@*****.**', self::ACCOUNT_PASSWORD); $reports = $accountService->createAccount('*****@*****.**', self::ACCOUNT_PASSWORD); $feedback = $accountService->createAccount('*****@*****.**', self::ACCOUNT_PASSWORD); $ac_all = new AccountAppAccess($all); $ac_all->allowAdmin(); $ac_all->allowFeedback(); $ac_all->allowReports(); $ac_admin = new AccountAppAccess($admin); $ac_admin->allowAdmin(); $ac_reports = new AccountAppAccess($reports); $ac_reports->allowReports(); $ac_feedback = new AccountAppAccess($feedback); $ac_feedback->allowFeedback(); $appAccessAccountService->applyAppAccess($ac_all); $appAccessAccountService->applyAppAccess($ac_admin); $appAccessAccountService->applyAppAccess($ac_reports); $appAccessAccountService->applyAppAccess($ac_feedback); self::$accounts = ['all' => $all, 'admin' => $admin, 'reports' => $reports, 'feedback' => $feedback]; }
public function up(Application $app, EntityManager $em) { $accountService = $app->getContainer()->get(AccountService::class); /** @var AccountService $accountService */ $currentAccountService = $app->getContainer()->get(CurrentAccountService::class); /** @var CurrentAccountService $currentAccountService */ $account = $accountService->createAccount(self::ACCOUNT_EMAIL, self::ACCOUNT_PASSWORD); $accountSecond = $accountService->createAccount(self::ACCOUNT_EMAIL_SECOND, self::ACCOUNT_PASSWORD); $currentAccountService->signInWithAccount($account); self::$account = $account; self::$secondAccount = $accountSecond; }
public function up(Application $app, EntityManager $em) { $profileId = DemoAccountFixture::getSecondAccount()->getCurrentProfile()->getId(); $service = $app->getContainer()->get(ProfileCommunitiesService::class); /** @var ProfileCommunitiesService $service */ self::$bookmarks = [1 => $service->joinToCommunity($profileId, SampleCommunitiesFixture::getCommunity(1)->getSID()), 2 => $service->joinToCommunity($profileId, SampleCommunitiesFixture::getCommunity(2)->getSID()), 3 => $service->joinToCommunity($profileId, SampleCommunitiesFixture::getCommunity(3)->getSID()), 4 => $service->joinToCommunity($profileId, SampleCommunitiesFixture::getCommunity(4)->getSID()), 5 => $service->joinToCommunity($profileId, SampleCommunitiesFixture::getCommunity(5)->getSID())]; }
public function up(Application $app, EntityManager $em) { $profile = DemoProfileFixture::getProfile(); $collectionService = $app->getContainer()->get(CollectionService::class); /** @var CollectionService $collectionService */ self::$profileCollections = [1 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('profile:%s', $profile->getId()), 'Profile Collection 1', 'My Profile Collection 1', [SampleThemesFixture::getTheme(1)->getId()])), 2 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('profile:%s', $profile->getId()), 'Profile Collection 1', 'My Profile Collection 2', [SampleThemesFixture::getTheme(2)->getId()])), 3 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('profile:%s', $profile->getId()), 'Profile Collection 1', 'My Profile Collection 3', [SampleThemesFixture::getTheme(3)->getId()])), 4 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('profile:%s', $profile->getId()), 'Profile Collection 1', 'My Profile Collection 4', [SampleThemesFixture::getTheme(4)->getId()])), 5 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('profile:%s', $profile->getId()), 'Profile Collection 1', 'My Profile Collection 5', [SampleThemesFixture::getTheme(5)->getId()]))]; self::$communityCollections = [1 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('community:%s', SampleCommunitiesFixture::getCommunity(1)->getId()), 'Community Collection 1', 'My Community Collection 1', [SampleThemesFixture::getTheme(1)->getId()])), 2 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('community:%s', SampleCommunitiesFixture::getCommunity(2)->getId()), 'Community Collection 2', 'My Community Collection 2', [SampleThemesFixture::getTheme(2)->getId()])), 3 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('community:%s', SampleCommunitiesFixture::getCommunity(3)->getId()), 'Community Collection 3', 'My Community Collection 3', [SampleThemesFixture::getTheme(3)->getId()])), 4 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('community:%s', SampleCommunitiesFixture::getCommunity(4)->getId()), 'Community Collection 4', 'My Community Collection 4', [SampleThemesFixture::getTheme(4)->getId()])), 5 => $collectionService->createCollection(new CreateCollectionParameters(sprintf('community:%s', SampleCommunitiesFixture::getCommunity(5)->getId()), 'Community Collection 5', 'My Community Collection 5', [SampleThemesFixture::getTheme(5)->getId()]))]; }
private function setupEvents(Application $app, EventEmitter $emitter, $eventConfigFile) { if (file_exists($eventConfigFile)) { $callback = (require $eventConfigFile); if (!is_callable($callback)) { throw new \Exception(sprintf('Event config `%s` should returns a Callable with EventEmitter and Container argument', $eventConfigFile)); } $result = $callback($emitter, $app->getContainer()); if (is_array($result) && count($result)) { Chain::create($result)->map(function (string $script) use($app) { return $app->getContainer()->get($script); })->map(function (EventsBootstrapInterface $script) use($emitter) { $script->up($emitter); }); } } }
public function up(Application $app, EntityManager $em) { $postService = $app->getContainer()->get(PostService::class); /** @var PostService $postService */ for ($i = 0; $i < 10; $i++) { self::$posts[$i] = $postService->createPost(new CreatePostParameters(DefaultPostType::CODE_INT, DemoAccountFixture::getAccount()->getCurrentProfile()->getId(), SampleCollectionsFixture::getProfileCollection(1)->getId(), 'Demo Post Content', [])); } }
public function __invoke(Application $app) { $this->app = $app; $this->routesGroup = $this->app->getContainer()->get("config.routes_group"); $bundleService = $app->getContainer()->get(BundleService::class); /** @var BundleService $bundleService */ $configDirs = array_map(function (Bundle $bundle) { return $bundle->getConfigDir(); }, $bundleService->getBundles()); $definitions = $this->getDefinitions($configDirs); $this->setupRoutes($definitions); }
public function up(Application $app, EntityManager $em) { $subscribeService = $app->getContainer()->get(SubscribeService::class); $profile = DemoAccountFixture::getAccount()->getCurrentProfile(); $theme = SampleThemesFixture::getTheme(1); self::$subscribes['theme'][0] = $subscribeService->subscribeTheme($profile, $theme); $subscribeProfile = DemoProfileFixture::getProfile(); self::$subscribes['profile'][0] = $subscribeService->subscribeProfile($profile, $subscribeProfile); $collections = SampleCollectionsFixture::getCommunityCollections(); $collection = array_shift($collections); self::$subscribes['collection'][0] = $subscribeService->subscribeCollection($profile, $collection); $community = SampleCommunitiesFixture::getCommunity(1); self::$subscribes['community'][0] = $subscribeService->subscribeCommunity($profile, $community); }
public function up(Application $app, EntityManager $em) { $themeService = $app->getContainer()->get(ThemeService::class); /** @var ThemeService $themeService */ self::$themes = [1 => $themeService->createTheme(new CreateThemeParameters('Theme 1', 'My Theme 1')), 2 => $themeService->createTheme(new CreateThemeParameters('Theme 2', 'My Theme 2')), 3 => $themeService->createTheme(new CreateThemeParameters('Theme 3', 'My Theme 3')), 4 => $themeService->createTheme(new CreateThemeParameters('Theme 4', 'My Theme 4')), 5 => $themeService->createTheme(new CreateThemeParameters('Theme 5', 'My Theme 5'))]; }
/** * Возвращает ссылку на контейнер текущего приложения * Используйте для получение сервисов/репозиторие/etc * @return Container */ protected function container() : Container { return self::$app->getContainer(); }
public function testCallingGetContainerWhenNoContainerComposedWillRaiseException() { $app = new Application($this->router->reveal()); $this->setExpectedException('RuntimeException'); $app->getContainer(); }
public function up(Application $app, EntityManager $em) { $communityService = $app->getContainer()->get(CommunityService::class); /** @var CommunityService $communityService */ self::$communities = [1 => $communityService->createCommunity(new CreateCommunityParameters('Community 1', 'My Community 1', SampleThemesFixture::getTheme(1)->getId())), 2 => $communityService->createCommunity(new CreateCommunityParameters('Community 2', 'My Community 2', SampleThemesFixture::getTheme(2)->getId())), 3 => $communityService->createCommunity(new CreateCommunityParameters('Community 3', 'My Community 3', SampleThemesFixture::getTheme(3)->getId())), 4 => $communityService->createCommunity(new CreateCommunityParameters('Community 4', 'My Community 4', SampleThemesFixture::getTheme(4)->getId())), 5 => $communityService->createCommunity(new CreateCommunityParameters('Community 5', 'My Community 5', SampleThemesFixture::getTheme(5)->getId()))]; }