Rebind service provider's container.

@param $app
@param $provider
496031
protected function rebindProviderContainer($app, $provider)
    {
        $closure = function () use ($app) {
            $this->app = $app;
        };

        $resetProvider = $closure->bindTo($provider, $provider);
        $resetProvider();
    }
1294580
public function register(Application $app)
    {
        $this->loadConfigurations($app);
        $this->registerServices($app);
        $this->registerEventListener($app);
    }
845997
public function ensureIlluminateBase(Container $app = null)
    {
        if (! $app->bound('events')) {
            $app->singleton('events', $this->illuminateClasses['events']);
            $app['events']->fire('booting');
        }

        if (! $app->bound('files')) {
            $app->bindIf('files', $this->illuminateClasses['files']);
        }
    }
522871
public function register($app)
    {
        if (!$this->isRegistered) {
            $this->loadSystemRoutes($app['router']);

            $serviceProviderPath = $this->getServiceProviderPath();
            if (is_file($serviceProviderPath)) {
                $this->provider = $app->register($this->getNamespace().'\Providers\ModuleServiceProvider');
            }

            $this->isRegistered = true;
        }

        return $this;
    }
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();
        }
    }
1215223
protected function setupEventFiring(Container $app)
    {
        $app['view']->composer('*', function ($view) use ($app) {
            if ($view instanceof View) {
                $app['events']->dispatch('content.rendering', [$view]);
            }
        });
    }
977115
public function onConstruct($app)
    {
        //if not null
        if (!is_null($app)) {
            $key = $this->settingsKey;
            $this->$key = $app;
        }
    }
677157
public function register(Container $app)
    {
        $app['console.name'] = 'Silex console';
        $app['console.version'] = 'UNKNOWN';
        // Assume we are in vendor/knplabs/console-service-provider/Knp/Provider
        $app['console.project_directory'] = __DIR__.'/../../../../..';
        $app['console.class'] = ConsoleApplication::class;
        // List of command service ids indexed by command name (i.e: array('my:command' => 'my.command.service.id'))
        $app['console.command.ids'] = [];

        // Maintain BC with projects that depend on the old behavior (application gets booted from console constructor)
        $app['console.boot_in_constructor'] = false;

        $app['console'] = function () use ($app) {
            /** @var ConsoleApplication $console */
            $console = new $app['console.class'](
                $app,
                $app['console.project_directory'],
                $app['console.name'],
                $app['console.version']
            );
            $console->setDispatcher($app['dispatcher']);

            foreach ($app['console.command.ids'] as $id) {
                $console->add($app[$id]);
            }

            if ($app['dispatcher']->hasListeners(ConsoleEvents::INIT)) {
                @trigger_error('Listening to the Knp\Console\ConsoleEvents::INIT event is deprecated and will be removed in v3 of the service provider. You should extend the console service instead.', E_USER_DEPRECATED);

                $app['dispatcher']->dispatch(ConsoleEvents::INIT, new ConsoleEvent($console));
            }

            return $console;
        };

        $commands = [];

        if (isset($app['twig']) && class_exists(TwigBridgeDebugCommand::class)) {
            $app['console.command.twig.debug'] = function (Container $container) {
                return new DebugCommand($container);
            };

            $app['console.command.twig.lint'] = function (Container $container) {
                return new LintCommand($container);
            };

            $commands['debug:twig'] = 'console.command.twig.debug';
            $commands['lint:twig'] = 'console.command.twig.lint';
        }

        if (class_exists(LintYamlCommand::class)) {
            $app['console.command.yaml.lint'] = function () {
                return new LintYamlCommand();
            };
            $commands['lint:yaml'] = 'console.command.yaml.lint';
        }

        $app['console.command.ids'] = $commands;
    }
1317946
private function initializeConfig(Application $app)
    {
        $config_provider = $app->make('Concrete\Core\Config\ConfigServiceProvider');
        $config_provider->register();

        /*
         * @var \Concrete\Core\Config\Repository\Repository
         */
        $config = $app->make('config');

        return $config;
    }
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);
    }
184657
public function registerInterfaceBindings(Application $app)
    {
        $app->bind(ClientInterface::class, FluentClient::class);
        $app->bind(ScopeInterface::class, FluentScope::class);
        $app->bind(SessionInterface::class, FluentSession::class);
        $app->bind(AuthCodeInterface::class, FluentAuthCode::class);
        $app->bind(AccessTokenInterface::class, FluentAccessToken::class);
        $app->bind(RefreshTokenInterface::class, FluentRefreshToken::class);
    }
219824
protected function setupEventListening(Container $app)
    {
        $app['events']->listen('content.rendering', function (View $view) use ($app) {
            if ($viewData = array_merge($view->getFactory()->getShared(), $view->getData())) {
                $decorator = $app['autopresenter'];
                foreach ($viewData as $key => $value) {
                    $view[$key] = $decorator->decorate($value);
                }
            }
        });
    }
453972
protected function instantiateUploadAdapters(Container $app)
    {
        /** @var Settings $settings */
        $settings = $app->make(Settings::class);

        $settings->getMimeTypesConfiguration()
            ->each(function ($mimetype) use ($app, $settings) {
                $adapter = Arr::get($mimetype, 'adapter', $mimetype);

                // Skip if already bound.
                if ($app->bound("flagrow.upload-adapter.$adapter")) {
                    return;
                }

                $app->bind("flagrow.upload-adapter.$adapter", function () use ($settings, $adapter) {
                    switch ($adapter) {
                        case 'aws-s3':
                            if (class_exists(S3Client::class)) {
                                return $this->awsS3($settings);
                            }
                        case 'ovh-svfs':
                            if (class_exists(OVHClient::class)) {
                                return $this->ovh($settings);
                            }
                        case 'imgur':
                            return $this->imgur($settings);

                        default:
                            return $this->local($settings);
                    }
                });
            });
    }
773013
public function postHandle($app)
    {
        $container = $app->getContainer();

        if ($container->has('doctrine')) {
            $doctrineRegistry = $container->get("doctrine");
            foreach ($doctrineRegistry->getManagers() as $curManagerName => $curManager) {
                if (!$curManager->isOpen()) {
                    $doctrineRegistry->resetManager($curManagerName);
                } else {
                    $curManager->clear();
                }
            }
        }

        //resets stopwatch, so it can correctly calculate the execution time
        if ($container->has('debug.stopwatch')) {
            $container->get('debug.stopwatch')->__construct();
        }

        //Symfony\Bundle\TwigBundle\Loader\FilesystemLoader
        //->Twig_Loader_Filesystem
        if ($this->debug && $container->has('twig.loader')) {
            $twigLoader = $container->get('twig.loader');
            Utils::bindAndCall(function () use ($twigLoader) {
                foreach ($twigLoader->cache as $path) {
                    register_file($path);
                }
            }, $twigLoader);
        }

        //reset Webpack Encore file list
        Utils::bindAndCall(function () use ($container) {
            if (isset($container->privates['webpack_encore.entrypoint_lookup'])) {
                $container->privates['webpack_encore.entrypoint_lookup']->reset();
            }
        }, $container);
        
        //reset all profiler stuff currently supported
        if ($container->has('profiler')) {
            $profiler = $container->get('profiler');

            // since Symfony does not reset Profiler::disable() calls after each request, we need to do it,
            // so the profiler bar is visible after the second request as well.
            $profiler->enable();

            //PropelLogger
            if ($container->has('propel.logger')) {
                $propelLogger = $container->get('propel.logger');
                Utils::hijackProperty($propelLogger, 'queries', []);
            }

            //Doctrine
            //Doctrine\Bundle\DoctrineBundle\DataCollector\DoctrineDataCollector
            if ($profiler->has('db')) {
                Utils::bindAndCall(function () {
                    //$logger: \Doctrine\DBAL\Logging\DebugStack
                    foreach ($this->loggers as $logger) {
                        Utils::hijackProperty($logger, 'queries', []);
                    }
                }, $profiler->get('db'), null, 'Symfony\Bridge\Doctrine\DataCollector\DoctrineDataCollector');
            }

            //EventDataCollector
            if ($profiler->has('events')) {
                Utils::hijackProperty($profiler->get('events'), 'data', [
                    'called_listeners' => [],
                    'not_called_listeners' => [],
                ]);
            }

            //TwigDataCollector
            if ($profiler->has('twig')) {
                Utils::bindAndCall(function () {
                    Utils::hijackProperty($this->profile, 'profiles', []);
                }, $profiler->get('twig'));
            }

            //Logger
            if ($container->has('logger')) {
                $logger = $container->get('logger');
                Utils::bindAndCall(function () {
                    if (\method_exists($this, 'getDebugLogger') && $debugLogger = $this->getDebugLogger()) {
                        //DebugLogger
                        Utils::hijackProperty($debugLogger, 'records', []);
                    }
                }, $logger);
            }

            //SwiftMailer logger
            //Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector
            if ($container->hasParameter('swiftmailer.mailers')) {
                $mailers = $container->getParameter('swiftmailer.mailers');
                foreach ($mailers as $name => $mailer) {
                    $loggerName = sprintf('swiftmailer.mailer.%s.plugin.messagelogger', $name);
                    if ($container->has($loggerName)) {
                        /** @var \Swift_Plugins_MessageLogger $logger */
                        $logger = $container->get($loggerName);
                        $logger->clear();
                    }
                }
            }

            //Symfony\Bridge\Swiftmailer\DataCollector\MessageDataCollector
            if ($container->has('swiftmailer.plugin.messagelogger')) {
                $logger = $container->get('swiftmailer.plugin.messagelogger');
                $logger->clear();
            }
        }
    }
961283
public function register(Container $app)
    {
        $app['sanity.client.options'] = [
            'projectId' => null,
            'dataset' => null,
        ];

        $app['sanity.client'] = function (Application $app) {
            return new Client($app['sanity.client.options']);
        };
    }
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,
        ]);
    }
632141
public function bootstrap(Application $app)
    {
        $this->setApp($app);

        error_reporting(-1);

        if (config('app.debug')) {
            Debug::enable(E_ALL, true);
        } else {
            Debug::enable(E_ALL & ~E_NOTICE, false);
        }

//        $handler = set_error_handler('var_dump');
//        $handler = is_array($handler) ? $handler[0] : null;
//        restore_error_handler();
//
//        if ($handler instanceof ErrorHandler) {
//            $app->getContainer()->share(ErrorHandler::class, $handler);
//        }
    }