Boot the application events.

@param RepositoryInterface $modules
@param Container           $container
348937
public function boot(RepositoryInterface $modules, Container $container)
    {
        $this->modules = $modules;
        $this->container = $container;

        App::booted(function ($app) {
            $this->defineMenuBuilder();
        });
    }
374362
public function boot( Container $container ) {
		add_action( 'admin_init', [ $this->proxy( $container, 'options_page' ), 'admin_init' ] );
		add_action( 'admin_menu', [ $this->proxy( $container, 'options_page' ), 'admin_menu' ] );
		add_action(
			'admin_notices',
			[ $this->proxy( $container, 'options_page' ), 'print_notice_when_no_notifiers_active' ]
		);
		add_action(
			'admin_init',
			[ $this->proxy( $container, 'options_manager' ), 'register_settings' ]
		);
		add_action( 'soter_run_check', [ $this->proxy( $container, 'check_site_job' ), 'run' ] );
		add_action(
			'soter_site_check_complete',
			[ $this->proxy( $container, 'notifier_manager' ), 'notify' ]
		);

		$this->boot_upgrader( $container );
	}
612299
public function process(\Symfony\Component\DependencyInjection\ContainerBuilder $container)
    {
        if (!$container->hasDefinition("thelia.admin.resources")) {
            return;
        }

        /** @var \Symfony\Component\DependencyInjection\Definition $adminResources */
        $adminResources = $container->getDefinition("thelia.admin.resources");

        $adminResources->addMethodCall("addModuleResources", [$this->getResources(), $this->getModuleCode()]);
    }
857663
public function build(ContainerBuilder $container)
    {
        $this->initAdmingeneratorClassLoader($container);

        parent::build($container);

        $container->addCompilerPass(new ValidatorCompilerPass());
        $container->addCompilerPass(new FormCompilerPass());
    }
1192812
private static function injectContainerToMigrations(ContainerInterface $container, array $versions) : void
    {
        foreach ($versions as $version) {
            $migration = $version->getMigration();
            if (! ($migration instanceof ContainerAwareInterface)) {
                continue;
            }

            $migration->setContainer($container);
        }
    }
1022479
public function boot(Dispatcher $events)
    {
        parent::boot($events);

        $events->listen('module.enabled', function ($module) {
            $permissionManager = new PermissionManager();
            $permissionManager->registerDefault($module);
        });
/*
        $events->listen('module.disabled', function ($module) {
            $permissionManager = new PermissionManager();
            $permissionManager->rollbackDefault($module);
        });
*/

        $events->listen('auth.login', function ($user) {
            $user->last_login = Carbon::now();
            $user->save();
        });
    }
711645
public function boot(Container $app)
    {
        $app->singleton('files', Filesystem::class);

        $app->singleton('events', function ($app) {
            return new Dispatcher($app);
        });

        $app->bind(Builder::class, function ($app) {
            return new Builder($app, $app['config']['build.pipeline']);
        });

        $app->bind(Factory::class, function ($app)
        {
            $engineResolver = $app->make(EngineResolver::class);

            $viewFinder = $app->make(FileViewFinder::class, [
                $app['files'],
                [
                    $app['config']['source.directory']
                ]
            ]);

            return new Factory($engineResolver, $viewFinder, $app['events']);
        });

        $this->bindAliasesForPipeline($app);
    }
226991
public function process(ContainerBuilder $container): void
    {
        $resolver = $container->findDefinition('fivelab.resource.serializer_resolver');
        $services = $container->findTaggedServiceIds('resource.serializer');

        foreach ($services as $serviceId => $tags) {
            try {
                $attributes = $tags[0];

                if (!array_key_exists('supportable', $attributes)) {
                    throw new \RuntimeException('The resource serializer should define with supportable instance. Please add the "supportable" attribute to "resource.assembler".');
                }

                $serializerDefinition = $container->getDefinition($serviceId);
                $serializerClass = $container->getParameterBag()->resolveValue($serializerDefinition->getClass());

                if (!is_a($serializerClass, ResourceSerializerInterface::class, true)) {
                    throw new \RuntimeException(sprintf(
                        'The resource serializer should implement "%s".',
                        ResourceSerializerInterface::class
                    ));
                }

                $supportableServiceId = $attributes['supportable'];

                $resolver->addMethodCall('add', [
                    new Reference($supportableServiceId),
                    new Reference($serviceId),
                ]);
            } catch (\Exception $e) {
                throw new \RuntimeException(sprintf(
                    'Can\'t compile resource serializer with service id "%s".',
                    $serviceId
                ), 0, $e);
            }
        }
    }
138880
private function initAdmingeneratorClassLoader(ContainerInterface $container)
    {
        if (!$this->classLoaderInitialized) {
            $this->classLoaderInitialized = true;

            $AdmingeneratedClassLoader = new AdmingeneratedClassLoader();
            $AdmingeneratedClassLoader->setBasePath($container->getParameter('kernel.cache_dir'));
            $AdmingeneratedClassLoader->register();
        }
    }
970830
public function rollback(ContainerInterface $container): void
    {
        foreach ($this->getRollbacks($container) as $class) {
            assert(is_string($class));
            $this->getIO()->writeInfo("Starting rollback for `$class`..." . PHP_EOL, IoInterface::VERBOSITY_VERBOSE);
            if (($migration = $this->createMigration($class, $container)) !== null) {
                $migration->init($container)->rollback();
                $this->getIO()->writeInfo("Rollback finished for `$class`." . PHP_EOL, IoInterface::VERBOSITY_NORMAL);
            }
        }

        $manager = $this->getConnection($container)->getSchemaManager();
        if ($manager->tablesExist([static::MIGRATIONS_TABLE]) === true) {
            $manager->dropTable(static::MIGRATIONS_TABLE);
        }
        if ($manager->tablesExist([static::SEEDS_TABLE]) === true) {
            $manager->dropTable(static::SEEDS_TABLE);
        }
    }
752608
protected function run(ContainerInterface $container, IoInterface $inOut): void
    {
        $item     = $inOut->getArguments()[static::ARG_ITEM];
        $singular = $inOut->getArguments()[static::ARG_SINGULAR];
        $plural   = $inOut->getArguments()[static::ARG_PLURAL];

        if ($this->isValidShortClassName($singular) === false) {
            throw new InvalidArgumentException("`$singular` is not a valid class name.");
        }
        if ($this->isValidShortClassName($plural) === false) {
            throw new InvalidArgumentException("`$plural` is not a valid class name.");
        }

        /** @var FileSystemInterface $fileSystem */
        $fileSystem = $container->get(FileSystemInterface::class);
        /** @var SettingsProviderInterface $settingsProvider */
        $settingsProvider = $container->get(SettingsProviderInterface::class);

        $dataTemplates = function () use ($settingsProvider, $fileSystem, $singular, $plural) : array {
            return [
                $this->composeMigration($settingsProvider, $fileSystem, $singular, $plural),
                $this->composeSeed($settingsProvider, $fileSystem, $singular, $plural),
                $this->composeModel($settingsProvider, $fileSystem, $singular, $plural),
            ];
        };

        $basicTemplates = function () use ($settingsProvider, $fileSystem, $singular, $plural) : array {
            return [
                $this->composeSchema($settingsProvider, $fileSystem, $singular, $plural),
                $this->composeAuthorization($settingsProvider, $fileSystem, $singular, $plural),
                $this->composeApi($settingsProvider, $fileSystem, $singular, $plural),
                $this->composeValidationRules($settingsProvider, $fileSystem, $singular, $plural),
                $this->composeQueryValidationOnReadRules($settingsProvider, $fileSystem, $singular, $plural),
            ];
        };

        $webTemplates = function () use ($settingsProvider, $fileSystem, $singular, $plural) : array {
            return [
                $this->composeWebValidationOnCreateRules($settingsProvider, $fileSystem, $singular),
                $this->composeWebValidationOnUpdateRules($settingsProvider, $fileSystem, $singular),
                $this->composeWebController($settingsProvider, $fileSystem, $singular, $plural),
                $this->composeWebRoute($settingsProvider, $fileSystem, $singular, $plural),
            ];
        };

        $jsonTemplates = function () use ($settingsProvider, $fileSystem, $singular, $plural) : array {
            return [
                $this->composeJsonValidationOnCreateRules($settingsProvider, $fileSystem, $singular),
                $this->composeJsonValidationOnUpdateRules($settingsProvider, $fileSystem, $singular),
                $this->composeJsonController($settingsProvider, $fileSystem, $singular, $plural),
                $this->composeJsonRoute($settingsProvider, $fileSystem, $singular, $plural),
            ];
        };

        switch ($item) {
            case static::ITEM_DATA_RESOURCE:
                $this->createTemplates($fileSystem, array_merge(
                    $dataTemplates()
                ));
                break;
            case static::ITEM_WEB_RESOURCE:
                $this->createTemplates($fileSystem, array_merge(
                    $dataTemplates(),
                    $basicTemplates(),
                    $webTemplates()
                ));
                break;
            case static::ITEM_JSON_API_RESOURCE:
                $this->createTemplates($fileSystem, array_merge(
                    $dataTemplates(),
                    $basicTemplates(),
                    $jsonTemplates()
                ));
                break;
            case static::ITEM_FULL_RESOURCE:
                $this->createTemplates($fileSystem, array_merge(
                    $dataTemplates(),
                    $basicTemplates(),
                    $webTemplates(),
                    $jsonTemplates()
                ));
                break;
            default:
                $inOut->writeError("Unsupported item type `$item`." . PHP_EOL);
                break;
        }
    }
564524
public function run(\Asgard\Container\ContainerInterface $container) {
		parent::run($container);

		#Files
		$container['rulesregistry']->registerNamespace('Asgard\File\Rule');

		#ORMInterface
		$container['rulesregistry']->registerNamespace('Asgard\Orm\Rule');

		#Controllers Templates
		$container['httpKernel']->addTemplatePathSolver(function($viewable, $template) {
			if(!$viewable instanceof \Asgard\Http\LambdaController) {
				$r = new \ReflectionClass($viewable);
				$viewableName = basename(str_replace('\\', DIRECTORY_SEPARATOR, get_class($viewable)));
				$viewableName = strtolower(preg_replace('/Controller$/i', '', $viewableName));

				if($viewable instanceof \Asgard\Http\Controller)
					$format = $viewable->request->format();
				else
					$format = 'html';

				$file = realpath(dirname($r->getFileName()).'/../'.$format.'/'.$viewableName.'/'.$template.'.php');
				if(!file_exists($file))
					return realpath(dirname($r->getFileName()).'/../html/'.$viewableName.'/'.$template.'.php');
				else
					return $file;
			}
		});

		if($container->has('console')) {
			$root = $container['kernel']['root'];
			$em = $container['entityManager'];

			#generator
			$generateCommand = new \Asgard\Generator\Command\GenerateCommand($container['generator']);
			$container['console']->add($generateCommand);

			#if database is available
			if($container['config']['database']) {
				$mm = $container['MigrationManager'];
				$om = $container['ormMigrations'];
				$db = $container['db'];
				$schema = $container['schema'];
				$dataMapper = $container['dataMapper'];

				$migrationList = new \Asgard\Migration\Command\ListCommand($container['kernel']['root'].'/migrations', $db);
				$container['console']->add($migrationList);

				$migrationRemove = new \Asgard\Migration\Command\RemoveCommand($container['kernel']['root'].'/migrations', $db, $schema);
				$container['console']->add($migrationRemove);

				$migrationAdd = new \Asgard\Migration\Command\AddCommand($root.'/migrations', $db, $schema);
				$container['console']->add($migrationAdd);

				$dbCreate = new \Asgard\Db\Command\CreateCommand($db);
				$container['console']->add($dbCreate);

				$ormAutomigrate = new \Asgard\Orm\Command\AutoMigrateCommand($om);
				$container['console']->add($ormAutomigrate);

				$ormGenerateMigration = new \Asgard\Orm\Command\GenerateMigrationCommand($om);
				$container['console']->add($ormGenerateMigration);

				$ormPreviewMigration = new \Asgard\Orm\Command\PreviewMigrationCommand($om);
				$container['console']->add($ormPreviewMigration);

				$dbEmpty = new \Asgard\Db\Command\EmptyCommand($db);
				$container['console']->add($dbEmpty);

				$migrationMigrate = new \Asgard\Migration\Command\MigrateCommand($container['kernel']['root'].'/migrations', $db, $schema);
				$migrationMigrateOne = new \Asgard\Migration\Command\MigrateOneCommand($container['kernel']['root'].'/migrations', $db, $schema);
				$migrationRollback = new \Asgard\Migration\Command\RollbackCommand($root.'/migrations', $db, $schema);
				$migrationUnmigrate = new \Asgard\Migration\Command\UnmigrateCommand($root.'/migrations', $db, $schema);
				$migrationRefresh = new \Asgard\Migration\Command\RefreshCommand($container['kernel']['root'].'/migrations', $db, $schema);
				$install = new \Asgard\Core\Command\InstallCommand($db, $schema);
				$publish = new \Asgard\Core\Command\PublishCommand($db, $schema);
			}
			else {
				$migrationMigrate = new \Asgard\Migration\Command\MigrateCommand($container['kernel']['root'].'/migrations');
				$migrationMigrateOne = new \Asgard\Migration\Command\MigrateOneCommand($container['kernel']['root'].'/migrations');
				$migrationRollback = new \Asgard\Migration\Command\RollbackCommand($root.'/migrations');
				$migrationUnmigrate = new \Asgard\Migration\Command\UnmigrateCommand($root.'/migrations');
				$migrationRefresh = new \Asgard\Migration\Command\RefreshCommand($container['kernel']['root'].'/migrations');
				$install = new \Asgard\Core\Command\InstallCommand;
				$publish = new \Asgard\Core\Command\PublishCommand;

				$db = null;
				$mm = null;
			}

			#tester
			$httpKernel = $container['httpKernel'];
			$resolver = $container['resolver'];

			$runCommand = new \Asgard\Tester\Command\RunCommand($httpKernel, $resolver, $db, $mm);
			$container['console']->add($runCommand);

			$curlCommand = new \Asgard\Tester\Command\CurlCommand();
			$container['console']->add($curlCommand);

			$httpTests = new \Asgard\Tester\Command\GenerateTestsCommand($container['kernel']['root'].'/tests');
			$container['console']->add($httpTests);

			$config = $container['config']['tester.coverage'];
			$coverageCommand = new \Asgard\Tester\Command\CoverageCommand($config);
			$container['console']->add($coverageCommand);

			$container['console']->add($migrationMigrate);
			$container['console']->add($migrationMigrateOne);
			$container['console']->add($migrationRollback);
			$container['console']->add($migrationUnmigrate);
			$container['console']->add($migrationRefresh);
			$container['console']->add($install);
			$container['console']->add($publish);

			$translation = $container['translation'];
			$root = $container['kernel']['root'];
			$dir = $container['config']['translation.directories'];
			if(!$dir)
				$dir = [$root.'/app'];

			$exportCsvCommand = new \Asgard\Translation\Command\ExportCsvCommand($translation, $dir);
			$container['console']->add($exportCsvCommand);

			$importCommand = new \Asgard\Translation\Command\ImportCommand();
			$container['console']->add($importCommand);

			$exportYamlCommand = new \Asgard\Translation\Command\ExportYamlCommand($translation, $dir);
			$container['console']->add($exportYamlCommand);

			$migrationCreate = new \Asgard\Migration\Command\CreateCommand($container['kernel']['root'].'/migrations');
			$container['console']->add($migrationCreate);

			$compile = new \Asgard\Core\Command\CompileCommand($container['config']['compile'], $container['kernel']->getCompiledFile());
			$container['console']->add($compile);

			$showEnv = new \Asgard\Core\Command\ShowEnvironmentCommand($container['kernel']);
			$container['console']->add($showEnv);

			$switchEnv = new \Asgard\Core\Command\SwitchEnvironmentCommand($container['kernel']);
			$container['console']->add($switchEnv);

			$httpRoutes = new \Asgard\Http\Command\RoutesCommand($container['resolver']);
			$container['console']->add($httpRoutes);

			$containerServices = new \Asgard\Container\Command\ListCommand($root);
			$container['console']->add($containerServices);

			$cacheClear = new \Asgard\Cache\Command\ClearCommand($container['systemcache']);
			$container['console']->add($cacheClear);

			$configInit = new \Asgard\Config\Command\InitCommand($container['kernel']['root'].'/config');
			$container['console']->add($configInit);

			$dbInit = new \Asgard\Db\Command\InitCommand($container['kernel']['root'].'/config');
			$container['console']->add($dbInit);

			$httpBrowser = new \Asgard\Http\Command\BrowserCommand($container['httpKernel']);
			$container['console']->add($httpBrowser);
		}
	}
735785
public function process(ContainerBuilder $container)
    {
        $configuration = $container->get('configuration', ContainerInterface::NULL_ON_INVALID_REFERENCE);
        if ($configuration instanceof ConfigurationInterface) {
            $this->registerService($container, 'deployment_strategy', $configuration->getDeploymentStrategyClass());

            $connectionManager = $container->get('connection_manager', ContainerInterface::NULL_ON_INVALID_REFERENCE);
            if ($connectionManager instanceof ConnectionManagerInterface) {
                foreach ($configuration->getDeploymentConnectionClasses() as $connectionType => $connectionAdapterClass) {
                    $connectionManager->registerConnectionAdapter($connectionType, $connectionAdapterClass);
                }
            }
        }
    }
118101
private function defineRepositories(array $objects, ContainerBuilder $container)
    {
        foreach ($objects as $object => $services) {
            if (array_key_exists('model', $services)) {
                $repositoryDefinition = $this->getRepositoryDefinition($object, $services, $container);

                $container->setDefinition(
                    $this->getContainerKey('repository', $object),
                    $repositoryDefinition
                )->setPublic(true);
            }
        }
    }
1336099
public function boot()
    {
        $this->loader->loadManifest();

        foreach ($this->extensions as $extension) {
            try {
                $this->eventDispatcher->dispatch(new Booted($extension));

                $name = $extension->getPackage()->getName();

                $this->eventDispatcher->dispatch('extension.started', [$name, []]);
                $this->eventDispatcher->dispatch('extension.started: {$name}', [[]]);
                $this->eventDispatcher->dispatch(new ComponentStarted($name));

                $this->eventDispatcher->dispatch('extension.booted', [$name, []]);
                $this->eventDispatcher->dispatch('extension.booted: {$name}', [[]]);
                $this->eventDispatcher->dispatch(new ComponentBooted($name));
            } catch (Exception $e) {
                throw $e;
            }
        }

        $this->eventDispatcher->dispatch(new BootedAll());
        $this->eventDispatcher->dispatch('antares.extension: booted');
        $this->eventDispatcher->dispatch(new ComponentsBooted());

        $this->loader->writeManifest();
        $this->booted = true;
    }
689863
public function setContainer(ContainerInterface $container)
    {
        $this->container = $container;
        $this->container->delegate(
            new ReflectionContainer()
        );
        $this->container->add(self::class, $this);
        self::setInstance($this);
    }
715435
public function registerProviders(Container $container)
    {
        $sysProvider = new PackageProvider($this);
        $container->registerServiceProvider($sysProvider);

        $sysProvider->boot();

        $providers = (array) $this->get('providers');

        foreach ($providers as $interface => &$provider) {
            if ($provider === false) {
                continue;
            }

            if (is_subclass_of($provider, ServiceProviderInterface::class)) {
                // Handle provider
                if ($provider instanceof ClassMeta || (is_string($provider) && class_exists($provider))) {
                    $provider = $container->newInstance($provider);
                }

                if ($provider === false) {
                    continue;
                }

                $container->registerServiceProvider($provider);

                if ($provider instanceof BootableProviderInterface || method_exists($provider, 'boot')) {
                    $provider->boot($container);
                }
            } else {
                // Handle Service
                if (is_numeric($interface)) {
                    $container->prepareSharedObject($provider);
                } else {
                    $container->bindShared($interface, $provider);
                }
            }
        }

        foreach ($providers as $provider) {
            if ($provider === false) {
                continue;
            }

            if (is_subclass_of($provider, ServiceProviderInterface::class) && (
                $provider instanceof BootableDeferredProviderInterface
                || method_exists($provider, 'bootDeferred')
            )) {
                $provider->bootDeferred($container);
            }
        }
    }