Registra o provedor de serviços do singular.

@param Container $app
434727
public function register(Container $app)
    {
        $app['singular.packs'] = function () use ($app) {
            return new Container();
        };

        $app['singular.service_map'] = function () use ($app) {
            return new Container();
        };

        $app['singular.config_loader'] = function () use ($app) {
            return new ConfigLoader($app);
        };

        $app['singular.service_locator'] = function () use ($app) {
            return new ServiceLocator(
                $app['singular.packs'],
                $app['singular.service_map'],
                $app['singular.resolver']
            );
        };

        $app['singular.service_resolver'] = function () use ($app) {
            return new ServiceResolver($app);
        };

        $app['singular.resolver'] = function () use ($app) {
            return new Resolver(
                $app['singular.controller_resolver'],
                $app['singular.service_resolver']
            );
        };

        $app['singular.controller_locator'] = function () use ($app) {
            return new ControllerLocator(
                $app['singular.resolver'],
                $app['singular.packs'],
                $app['singular.service_map']
            );
        };

        $app['singular.controller_resolver'] = function () use ($app) {
            return new ControllerResolver($app);
        };
    }
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);
    }
1092880
public function boot(Application $app)
    {
        if (!$this->registered) {
            throw new \RuntimeException('Can not boot extensions prior to completion of registration.');
        }
        if ($this->booted) {
            throw new \RuntimeException('Can not re-boot extensions.');
        }

        // Boot all extension loaders that are also service providers
        foreach ($this->extensions as $extension) {
            if ($extension->isEnabled() !== true) {
                continue;
            }
            foreach ($extension->getInnerExtension()->getServiceProviders() as $provider) {
                $provider->boot($app);
            }
        }
        $this->loaded = true;
        $this->booted = true;
    }
776226
public function bootstrap(Container $app) {
	    $extensions = $this->manager->getAvailableExtensions()->filterByActivated();

        $this->dispatcher->registerCollection($extensions);
        $this->dispatcher->boot();
	}
1047552
protected function bootstrap($app): void
    {
        $app->bootstrapWith([
            \Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables::class,
            \CrCms\Microservice\Bootstrap\LoadConfiguration::class,
            \CrCms\Microservice\Bootstrap\HandleExceptions::class,
            \CrCms\Microservice\Bootstrap\RegisterFacades::class,
            //\Illuminate\Foundation\Bootstrap\SetRequestForConsole::class,
            \Illuminate\Foundation\Bootstrap\RegisterProviders::class,
            \Illuminate\Foundation\Bootstrap\BootProviders::class,
        ]);
    }
271639
protected function closeWebSocket(Container $app): void
    {
        /* @var Channel $channel */
        try {
            $channel = $this->currentChannel($this->fd);
        } catch (\Exception $exception) {
            echo "closeWebSocket: {$exception->getMessage()}, fd:{$this->fd}".PHP_EOL;
            $channel = null;
        }

        if (is_null($channel)) {
            return;
        }

        $websocket = (new Socket($app, $channel))->setFd($this->fd);

        $app->instance('websocket', $websocket);

        try {
            if ($channel->eventExists('disconnection')) {
                $channel->dispatch('disconnection');
            }
        } catch (\Exception $exception) {
            throw $exception;
        } finally {
            $websocket->leave();
        }
    }
270496
public function bootstrap($app)
    {

        Event::on(ProductController::className(),
            ProductController::EVENT_AFTER_CREATE_PRODUCT, [$this, 'invalidateCache']);
        Event::on(ProductController::className(),
            ProductController::EVENT_AFTER_EDIT_PRODUCT, [$this, 'invalidateCache']);
        Event::on(ProductController::className(),
            ProductController::EVENT_AFTER_DELETE_PRODUCT, [$this, 'invalidateCache']);

        Event::on(CategoryController::className(),
            CategoryController::EVENT_AFTER_CREATE_CATEGORY, [$this, 'invalidateCache']);
        Event::on(CategoryController::className(),
            CategoryController::EVENT_AFTER_EDIT_CATEGORY, [$this, 'invalidateCache']);
        Event::on(CategoryController::className(),
            CategoryController::EVENT_AFTER_DELETE_CATEGORY, [$this, 'invalidateCache']);

        Event::on(Category::className(),
            Category::EVENT_AFTER_DELETE, [$this, 'invalidateCache']);
        Event::on(Category::className(),
            Category::EVENT_AFTER_INSERT, [$this, 'invalidateCache']);
        Event::on(Category::className(),
            Category::EVENT_AFTER_UPDATE, [$this, 'invalidateCache']);

        Event::on(Product::className(),
            Product::EVENT_AFTER_DELETE, [$this, 'invalidateCache']);
        Event::on(Product::className(),
            Product::EVENT_AFTER_INSERT, [$this, 'invalidateCache']);
        Event::on(Product::className(),
            Product::EVENT_AFTER_UPDATE, [$this, 'invalidateCache']);

        Event::on(Vendor::className(),
            Vendor::EVENT_AFTER_DELETE, [$this, 'invalidateCache']);
        Event::on(Vendor::className(),
            Vendor::EVENT_AFTER_INSERT, [$this, 'invalidateCache']);
        Event::on(Vendor::className(),
            Vendor::EVENT_AFTER_UPDATE, [$this, 'invalidateCache']);

        Event::on(Vendor::className(),
            Vendor::EVENT_AFTER_DELETE, [$this, 'invalidateCache']);
        Event::on(Vendor::className(),
            Vendor::EVENT_AFTER_INSERT, [$this, 'invalidateCache']);
        Event::on(Vendor::className(),
            Vendor::EVENT_AFTER_UPDATE, [$this, 'invalidateCache']);

        Event::on(ProductAvailability::className(),
            ProductAvailability::EVENT_AFTER_DELETE, [$this, 'invalidateCache']);
        Event::on(ProductAvailability::className(),
            ProductAvailability::EVENT_AFTER_INSERT, [$this, 'invalidateCache']);
        Event::on(ProductAvailability::className(),
            ProductAvailability::EVENT_AFTER_UPDATE, [$this, 'invalidateCache']);

        Event::on(ShopAttribute::className(),
            ShopAttribute::EVENT_AFTER_DELETE, [$this, 'invalidateCache']);
        Event::on(ShopAttribute::className(),
            ShopAttribute::EVENT_AFTER_INSERT, [$this, 'invalidateCache']);
        Event::on(ShopAttribute::className(),
            ShopAttribute::EVENT_AFTER_UPDATE, [$this, 'invalidateCache']);

        Event::on(ShopAttributeValue::className(),
            ShopAttributeValue::EVENT_AFTER_DELETE, [$this, 'invalidateCache']);
        Event::on(ShopAttributeValue::className(),
            ShopAttributeValue::EVENT_AFTER_INSERT, [$this, 'invalidateCache']);
        Event::on(ShopAttributeValue::className(),
            ShopAttributeValue::EVENT_AFTER_UPDATE, [$this, 'invalidateCache']);

        Event::on(ProductCountry::className(),
            ProductCountry::EVENT_BEFORE_DELETE, [$this, 'invalidateCache']);
        Event::on(ProductCountry::className(),
            ProductCountry::EVENT_BEFORE_INSERT, [$this, 'invalidateCache']);
        Event::on(ProductCountry::className(),
            ProductCountry::EVENT_BEFORE_UPDATE, [$this, 'invalidateCache']);

        Event::on(FavoriteProduct::className(),
            FavoriteProduct::EVENT_AFTER_DELETE, [$this, 'invalidateCache']);
        Event::on(FavoriteProduct::className(),
            FavoriteProduct::EVENT_AFTER_INSERT, [$this, 'invalidateCache']);
        Event::on(FavoriteProduct::className(),
            FavoriteProduct::EVENT_AFTER_UPDATE, [$this, 'invalidateCache']);

        Event::on(CartComponent::className(),
            CartComponent::EVENT_AFTER_CLEAR, [$this, 'invalidateCache']);
        Event::on(CartComponent::className(),
            CartComponent::EVENT_AFTER_ADD_PRODUCT, [$this, 'invalidateCache']);
        Event::on(CartComponent::className(),
            CartComponent::EVENT_AFTER_REMOVE_PRODUCT, [$this, 'invalidateCache']);
        Event::on(CartComponent::className(),
            CartComponent::EVENT_BEFORE_GET_ORDER, [$this, 'invalidateCache']);
        Event::on(CartComponent::className(),
            CartComponent::EVENT_BEFORE_GET_ORDER_FROM_DB, [$this, 'invalidateCache']);

    }
84157
public function bootstrap(Application $app)
    {
        /** @var Container $container */
        $container = $app->getContainer();

        $container->share('app', $app);
        $container->alias('app', Application::class);
        $container->alias('app', ApplicationInterface::class);

        $container->share('container', $container);

        $container->share('kernel.http', function () use ($container) {
            return $container->get(Kernel::class);
        });
        $container->alias('kernel.http', KernelInterface::class);

        $container->alias('router', Router::class);
        $container->alias('dispatcher', Dispatcher::class);
    }
74301
public function register(Container $app)
    {
        $this->kernel                        = $app;
        $app['request_matcher']              = $app->extend(
            'request_matcher',
            function ($urlMatcher, $c) {
                $context = $c['request_context'];
                
                $newMatcher = new GroupUrlMatcher(
                    $context,
                    [
                        new CacheableRouterUrlMatcherWrapper(
                            $this->getRouter($context)->getMatcher(),
                            $c['routing.config.namespaces']
                        ),
                        $urlMatcher,
                    ]
                );
                
                return $newMatcher;
            }
        );
        $app['url_generator']                = $app->extend(
            'url_generator',
            function ($generator, $kernel) {
                /** @var SilexKernel $kernel */
                
                /** @var RequestContext $context */
                //$context = $kernel['request_context'];
                /** @var Router $router */
                $router       = $kernel['router'];
                $newGenerator = $router->getGenerator();
                
                //$newGenerator = new UrlGenerator($router->getRouteCollection(), $context);
                
                return new GroupUrlGenerator(
                    [
                        $newGenerator,
                        $generator,
                    ]
                );
            }
        );
        $app['router']                       = function ($app) {
            return $this->getRouter($app['request_context']);
        };
        $app['routing.config.data_provider'] = function ($app) {
            $routingConfig = $app['routing.config'];
            
            return $this->processConfiguration(
                $routingConfig,
                new CacheableRouterConfiguration()
            );
        };
        $app['routing.config.namespaces']    = function () {
            return $this->getConfigDataProvider()->getOptional(
                'namespaces',
                DataProviderInterface::ARRAY_TYPE,
                []
            );
        };
        $app['routing.config.cache_dir']     = function () {
            return $this->getConfigDataProvider()->getOptional('cache_dir');
        };
    }
21844
public function register(Container $app)
    {
        $app["cache.service"] = function(Container $app) {
            $handlerClass = ucfirst($app["config.service"]["cache.handler"]);

            return new \SlaxWeb\Cache\Manager(
                $app["cache{$handlerClass}Handler.service"]
            );
        };

        $app["cacheFileHandler.service"] = function(Container $app) {
            return new \SlaxWeb\Cache\Handler\File(
                $app["config.service"]["cache.location"],
                $app["config.service"]["cache.maxAge"]
            );
        };
    }
306997
public function bootstrap(Application $app)
    {
        AutoLoader::registerHandler($app->getAutoLoader());

        $app->getAutoLoader()->setCachePath(
            $app->storagePath() . DIRECTORY_SEPARATOR
            . 'cache' . DIRECTORY_SEPARATOR . "autoloader" . DIRECTORY_SEPARATOR
        );

        $app->setupAutoLoaderPaths();

//        if ($this->getStaging()->getStage()->inTesting()) {
        $app->getAutoLoader()->getClassMapLoader()->setRetry(true);
//        }
    }
1190183
public static function registerServices(Application $app)
    {
        $file = $app['wise.options']['config']['services'];

        if ('prod' !== $app['wise.options']['mode']) {
            $file .= '_' . $app['wise.options']['mode'];
        }

        $file .= '.' . $app['wise.options']['type'];

        /** @var $wise Wise */
        $wise = $app['wise'];
        $services = $wise->load($file);

        unset($services['parameters']);
        unset($services['imports']);

        foreach ($services as $name => $service) {
            if (null === $service) {
                continue;
            }

            if (!isset($service['class'])) {
                throw InvalidArgumentException::format(
                    'The service "%s" did not specify its "class".',
                    $name
                );
            }

            if (!isset($service['parameters'])) {
                $service['parameters'] = array();
            }

            $app->register(new $service['class'](), $service['parameters']);
        }
    }
975802
public function boot(Container $app)
    {
        $toBoot = (array) $app['config']->get('bootstrap', []);

        foreach ($toBoot as $bootstrapClass) {
            $app->make($bootstrapClass)->boot($app);
        }
    }
307688
protected function checkDependencies(Container $app)
    {
        $dependencies = [
            'twig' => 'TwigServiceProvider',
            'session' => 'SessionServiceProvider',
            'translator' => 'TranslationServiceProvider',
            'validator' => 'ValidatorServiceProvider',
            'form.factory' => 'FormServiceProvider',
            'security.token_storage' => 'SecurityServiceProvider'
        ];

        if (!$app['resolver'] instanceof ServiceControllerResolver) {
            throw new LogicException('You must register the ServiceControllerServiceProvider to use the UserServiceProvider');
        }

        foreach ($dependencies as $key => $provider) {
            if (!isset($app[$key])) {
                throw new LogicException(sprintf('You must register the %s to use the UserServiceProvider', $provider));
            }
        }
    }
972075
public function register(Application $App) {
        $App->addCommand(new \YourApp\Command\Foo());
        $App->addCommand(new \YourApp\Command\Bar());
        $App->addCommand(new \YourApp\Command\Baz());
    }
1273730
private function loadMiddlewares($app, $container)
    {
        # Tracy debugbar
        $debugbar_enabled = filter_var(app_env('DEBUG_BAR_ON', false), FILTER_VALIDATE_BOOLEAN);
        if (is_dev() && $debugbar_enabled && PHP_SAPI !== "cli")
        {
            $app->add(new TracyMiddleware($app));
        }

        # Determine Route Before Application middleware
        $app->add(new AppMiddleware($container));

        # Global Error middleware
        $app->add(new GlobalErrorsMiddleware($container));

        # Old Input middleware
        $app->add(new OldInputMiddleware($container));

        # Global Csrf middleware
        $app->add(new GlobalCsrfMiddleware($container));
        $app->add($container->get('csrf'));

        # Shared Server middleware
        $app->add(new SharedServerMiddleware($container));

        # Application Mode middleware
        $app->add(new AppModeMiddleware($container));

        # Remove Trailing Slash middleware
        $app->add(new RemoveTrailingSlashMiddleware($container));
    }
414889
protected function serviceRegistrar(string $type): void
	{
		foreach($this->config->get('application.services.' . $type) as $service)
		{
			(new $service($this, $this->container, $this->config))->register();
		}
	}