Bootstrap

@codeCoverageIgnore
331507
public function boot()
    {
        error_reporting(-1); // E_ALL
        set_exception_handler([$this, 'handleException']);
        set_error_handler([$this, 'handleError']);
        register_shutdown_function([$this, 'handleShutdown']);
        if (config('app.env') != 'testing') {
            ini_set('display_errors', 'Off');
        }
    }
1253131
public function bootstrap()
    {
        $identifiers = $this->_identifiers;
        $aliases     = $this->_aliases;

        if(!$this->isBootstrapped())
        {
            $manager = $this->getObject('manager');

            /*
             * Setup the component class locator
             *
             * Locators are always setup as the  cannot be cached in the registry objects.
             */
            foreach($this->_namespaces as $namespace => $path) {
                $manager->getClassLoader()->getLocator('component')->registerNamespace($namespace, $path);
            }

            /*
             * Load resources
             *
             * If cache is enabled and the bootstrapper has been run we do not reload the config resources
             */
            if(!$this->getConfig()->bootstrapped)
            {
                $factory = $this->getObject('object.config.factory');

                foreach($this->_files as $filename)
                {
                    $array = $factory->fromFile($filename, false);

                    if(isset($array['priority'])) {
                        $priority = $array['priority'];
                    } else {
                        $priority = self::PRIORITY_NORMAL;
                    }

                    if(isset($array['aliases']))
                    {
                        if(!isset($aliases[$priority])) {
                            $aliases[$priority] = array();
                        }

                        $aliases[$priority] = array_merge($aliases[$priority], $array['aliases']);;
                    }

                    if(isset($array['identifiers']))
                    {
                        if(!isset($identifiers[$priority])) {
                            $identifiers[$priority] = array();
                        }

                        foreach ($array['identifiers'] as $identifier => $config)
                        {
                            if (array_key_exists($identifier, $identifiers[$priority]))
                            {
                                $existing = new KObjectConfig($identifiers[$priority][$identifier]);
                                $existing->append($config);

                                $identifiers[$priority][$identifier] = $existing->toArray();
                            }
                            else $identifiers[$priority][$identifier] = $config;
                        }
                    }
                }

                /*
                * Set the identifiers
                *
                * Collect identifiers by priority and then flatten the array.
                */
                $identifiers_flat = array();

                krsort($identifiers);
                foreach ($identifiers as $priority => $merges) {
                    $identifiers_flat = array_replace_recursive($identifiers_flat, $merges);
                }

                foreach ($identifiers_flat as $identifier => $config) {
                    $manager->setIdentifier(new KObjectIdentifier($identifier, $config));
                }

                /*
                * Set the aliases
                *
                * Collect aliases by priority and then flatten the array.
                */
                $aliases_flat = array();

                foreach ($aliases as $priority => $merges) {
                    $aliases_flat = array_merge($merges, $aliases_flat);
                }

                foreach($aliases_flat as $alias => $identifier) {
                    $manager->registerAlias($identifier, $alias);
                }

                /*
                 * Reset the bootstrapper in the object manager
                 *
                 * If cache is enabled this will prevent the bootstrapper from reloading the config resources
                 */
                $identifier = new KObjectIdentifier('lib:object.bootstrapper', array(
                    'bootstrapped' => true,
                    'directories'  => $this->_directories,
                    'components'   => $this->_components,
                    'domains'      => $this->_domains,
                    'namespaces'   => $this->_namespaces,
                    'files'        => $this->_files,
                    'applications' => $this->_applications,
                    'aliases'      => $aliases_flat,
                ));

                $manager->setIdentifier($identifier)
                        ->setObject('lib:object.bootstrapper', $this);
            }
            else
            {
                foreach($aliases as $alias => $identifier) {
                    $manager->registerAlias($identifier, $alias);
                }
            }

            $this->_bootstrapped = true;
        }
    }
795848
public function bootstrap()
    {
        if (!$this->booted) {
            $this->container = $this->buildContainer();
            $this->router = $this->buildRouter();
            $this->booted = true;
        }
    }
1263165
public function _Bootstrap()
	{
		$this->forward()->setResponse(new HtmlResponse());
		$this->forward()->getCurrentRoute()->setDefault(new Route(array('action'=>'_error')));
	}
655330
public function bootstrap()
    {
        if (! defined('ABSPATH')) {
            define('ABSPATH', "{$this->path}/");
        }

        $_SERVER['DOCUMENT_ROOT']   = $this->path;
        $_SERVER['HTTP_HOST']       = '';
        $_SERVER['REQUEST_METHOD']  = 'GET';
        $_SERVER['REQUEST_URI']     = '/';
        $_SERVER['SERVER_NAME']     = '';
        $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';

        if (! file_exists("{$this->path}/index.php")) {
            throw new RuntimeException(sprintf('[W200] WordPress PHP driver cannot find WordPress at %s.', $this->path));
        }

        // "Cry 'Havoc!' and let slip the dogs of war".
        require_once "{$this->path}/wp-blog-header.php";

        if (! function_exists('activate_plugin')) {
            require_once "{$this->path}/wp-admin/includes/plugin.php";
            require_once "{$this->path}/wp-admin/includes/plugin-install.php";
        }

        $this->wpdb            = $GLOBALS['wpdb'];
        $this->is_bootstrapped = true;
    }
434432
protected function bootstrap()
    {
        $this->app->bootstrap();

        if ($this->app instanceof PluginApplicationInterface) {
            $this->app->pluginBootstrap();
        }
    }
1073364
public function bootstrap()
    {
        if (!$this->booted) {
            $config = load($this->path.'/config/app.php');
            $this->name = $config['name'];

            date_default_timezone_set(isset($config['timezone']) ? $config['timezone'] : 'UTC');

            $this->add('config', new Config($config));
            $this->add('logger', new Logger($this->name));

            $this->registerExceptionHandler();
            $this->registerServicesProviders($config['services']);

            unset($config);
            $this->booted = true;
        }
    }
1015506
public function boot()
    {
        Builder::macro('whereDecrypted', function($attribute, $operator = null, $value = null, $decryptKey = null){
            list($value, $operator, $decryptKey) = $this->query->prepareDecryptionValueOperatorAndDecryptKey(
                $value, $operator, $decryptKey, func_num_args() == 3
            );

            $model = $this->getModel();
            $encryptedFields = $model::getEncryptedFields();
            if (in_array($attribute, $encryptedFields)) {
                $encryptionService = $model::getEncryptionService();
                $this->whereRaw($encryptionService->getDecryptExpression($attribute, $decryptKey) . " " . $operator . " ?", [$value]);
            } else {
                $this->where($attribute, $operator, $value);
            }

            return $this;
        });

        Builder::macro('orWhereDecrypted', function($attribute, $operator = null, $value = null, $decryptKey = null){
            list($value, $operator, $decryptKey) = $this->query->prepareDecryptionValueOperatorAndDecryptKey(
                $value, $operator, $decryptKey, func_num_args() == 3
            );
            $model = $this->getModel();
            $encryptedFields = $model::getEncryptedFields();
            if (in_array($attribute, $encryptedFields)) {
                $encryptionService = $model::getEncryptionService();
                $this->orWhereRaw($encryptionService->getDecryptExpression($attribute, $decryptKey) . " " . $operator . " ?", [$value]);
            } else {
                $this->orWhere($attribute, $operator, $value);
            }
            return $this;
        });

        Builder::macro('orderByDecrypted', function($attribute, $direction = 'asc', $decryptKey = null){
            $model = $this->getModel();
            $encryptedFields = $model::getEncryptedFields();
            if (in_array($attribute, $encryptedFields)) {
                $encryptionService = $model::getEncryptionService();
                $this->orderByRaw($encryptionService->getDecryptExpression($attribute, $decryptKey) . " " . $direction);
            } else {
                $this->orderBy($attribute, $direction);
            }
            return $this;
        });
    }
722135
public function bootstrap()
    {

        // setup autoloader
        require SERVER_AUTOLOADER;

        // make the application available and register the class loaders
        $application = $this->getApplication();
        $application->registerClassLoaders();

        // register the applications annotation registries
        $application->registerAnnotationRegistries();

        // try to load the profile logger
        if (isset($this->loggers[LoggerUtils::PROFILE])) {
            $this->profileLogger = $this->loggers[LoggerUtils::PROFILE];
            $this->profileLogger->appendThreadContext('timer-factory');
        }
    }
928127
public function boot(Core\Bootstrap $bootstrap)
    {
        $context = $bootstrap->getContext();

        if (PHP_SAPI === 'cli') {
            $bootstrap->registerRequestHandler(new Cli\SlaveRequestHandler($bootstrap));
            $bootstrap->registerRequestHandler(new Cli\CommandRequestHandler($bootstrap));
        } else {
            $bootstrap->registerRequestHandler(new Http\RequestHandler($bootstrap));
        }

        if ($context->isTesting()) {
            $bootstrap->registerRequestHandler(new Tests\FunctionalTestRequestHandler($bootstrap));
        }

        $bootstrap->registerCompiletimeCommand('neos.flow:core:*');
        $bootstrap->registerCompiletimeCommand('neos.flow:cache:flush');
        $bootstrap->registerCompiletimeCommand('neos.flow:package:rescan');

        $dispatcher = $bootstrap->getSignalSlotDispatcher();
        $dispatcher->connect(Mvc\Dispatcher::class, 'afterControllerInvocation', function ($request) use ($bootstrap) {
            if ($bootstrap->getObjectManager()->has(Persistence\PersistenceManagerInterface::class)) {
                if (!$request instanceof Mvc\ActionRequest || SecurityHelper::hasSafeMethod($request->getHttpRequest()) !== true) {
                    $bootstrap->getObjectManager()->get(Persistence\PersistenceManagerInterface::class)->persistAll();
                } elseif (SecurityHelper::hasSafeMethod($request->getHttpRequest())) {
                    $bootstrap->getObjectManager()->get(Persistence\PersistenceManagerInterface::class)->persistAll(true);
                }
            }
        });
        $dispatcher->connect(Cli\SlaveRequestHandler::class, 'dispatchedCommandLineSlaveRequest', Persistence\PersistenceManagerInterface::class, 'persistAll');

        if (!$context->isProduction()) {
            $dispatcher->connect(Core\Booting\Sequence::class, 'afterInvokeStep', function (Step $step) use ($bootstrap, $dispatcher) {
                if ($step->getIdentifier() === 'neos.flow:resources') {
                    $publicResourcesFileMonitor = Monitor\FileMonitor::createFileMonitorAtBoot('Flow_PublicResourcesFiles', $bootstrap);
                    /** @var PackageManager $packageManager */
                    $packageManager = $bootstrap->getEarlyInstance(Package\PackageManager::class);
                    foreach ($packageManager->getFlowPackages() as $packageKey => $package) {
                        if ($packageManager->isPackageFrozen($packageKey)) {
                            continue;
                        }

                        $publicResourcesPath = $package->getResourcesPath() . 'Public/';
                        if (is_dir($publicResourcesPath)) {
                            $publicResourcesFileMonitor->monitorDirectory($publicResourcesPath);
                        }
                    }
                    $publicResourcesFileMonitor->detectChanges();
                    $publicResourcesFileMonitor->shutdownObject();
                }
            });

            $publishResources = function ($identifier) use ($bootstrap) {
                if ($identifier !== 'Flow_PublicResourcesFiles') {
                    return;
                }
                $objectManager = $bootstrap->getObjectManager();
                $resourceManager = $objectManager->get(ResourceManager::class);
                $resourceManager->getCollection(ResourceManager::DEFAULT_STATIC_COLLECTION_NAME)->publish();
            };

            $dispatcher->connect(Monitor\FileMonitor::class, 'filesHaveChanged', $publishResources);

            $dispatcher->connect(Monitor\FileMonitor::class, 'filesHaveChanged', Cache\CacheManager::class, 'flushSystemCachesByChangedFiles');
        }

        $dispatcher->connect(Core\Bootstrap::class, 'bootstrapShuttingDown', Configuration\ConfigurationManager::class, 'shutdown');
        $dispatcher->connect(Core\Bootstrap::class, 'bootstrapShuttingDown', ObjectManagement\ObjectManagerInterface::class, 'shutdown');

        $dispatcher->connect(Core\Bootstrap::class, 'bootstrapShuttingDown', Reflection\ReflectionService::class, 'saveToCache');

        $dispatcher->connect(Command\CoreCommandController::class, 'finishedCompilationRun', Security\Authorization\Privilege\Method\MethodPrivilegePointcutFilter::class, 'savePolicyCache');

        $dispatcher->connect(Security\Authentication\AuthenticationProviderManager::class, 'authenticatedToken', function () use ($bootstrap) {
            $session = $bootstrap->getObjectManager()->get(Session\SessionInterface::class);
            if ($session->isStarted()) {
                $session->renewId();
            }
        });

        $dispatcher->connect(Tests\FunctionalTestCase::class, 'functionalTestTearDown', Mvc\Routing\RouterCachingService::class, 'flushCaches');

        $dispatcher->connect(Configuration\ConfigurationManager::class, 'configurationManagerReady', function (Configuration\ConfigurationManager $configurationManager) {
            $configurationManager->registerConfigurationType('Views', Configuration\ConfigurationManager::CONFIGURATION_PROCESSING_TYPE_APPEND);
        });
        $dispatcher->connect(Command\CacheCommandController::class, 'warmupCaches', Configuration\ConfigurationManager::class, 'warmup');

        $dispatcher->connect(Package\PackageManager::class, 'packageStatesUpdated', function () use ($dispatcher, $bootstrap) {
            $dispatcher->connect(Core\Bootstrap::class, 'bootstrapShuttingDown', function () use ($bootstrap) {
                $bootstrap->getObjectManager()->get(Cache\CacheManager::class)->flushCaches();
            });
        });

        $dispatcher->connect(Persistence\Doctrine\EntityManagerFactory::class, 'beforeDoctrineEntityManagerCreation', Persistence\Doctrine\EntityManagerConfiguration::class, 'configureEntityManager');
        $dispatcher->connect(Persistence\Doctrine\EntityManagerFactory::class, 'afterDoctrineEntityManagerCreation', Persistence\Doctrine\EntityManagerConfiguration::class, 'enhanceEntityManager');

        $dispatcher->connect(Persistence\Doctrine\PersistenceManager::class, 'allObjectsPersisted', ResourceRepository::class, 'resetAfterPersistingChanges');
        $dispatcher->connect(Persistence\Generic\PersistenceManager::class, 'allObjectsPersisted', ResourceRepository::class, 'resetAfterPersistingChanges');

        $dispatcher->connect(AuthenticationProviderManager::class, 'successfullyAuthenticated', Context::class, 'refreshRoles');
        $dispatcher->connect(AuthenticationProviderManager::class, 'loggedOut', Context::class, 'refreshTokens');
    }
67826
protected function bootstrap()
    {
        foreach (static::$bootstrappers as $bootstrapper) {
            try{
                $bootstrapper($this);
            }catch (\Exception $e){
                echo $e->getMessage();
            }
        }
    }
323104
public function boot()
    {
        parent::boot();

        // add scripts and styles to be used globally.
        $this->codex()->theme
            ->addStylesheet('codex.phpdoc', asset('/vendor/codex/styles/codex.phpdoc.document.css'), [ 'codex' ])
            ->addJavascript('codex.phpdoc', asset('/vendor/codex/js/codex.phpdoc.js'), [ 'codex.page.document', 'codex' ])
            ->addJavascript('codex.page.phpdoc', asset('/vendor/codex/js/codex.page.phpdoc.js'), [ 'codex.phpdoc' ]);


        // 1. Ensure both the Codex plugin and CodexPhpdoc plugin are loaded for documents. This enables all phpdoc components for use in documents.
        // 2. Then make it so that the original init script (and its depends) run AFTER loading the plugins, by adding it as a dependency
        $this->hook('controller:document', function ($controller, Document $document) {
            if ( false === $document->getProject()->config('phpdoc.enabled', false) ) {
                return;
            }
            $this->codex()->theme
                ->set('phpdoc.url', $document->getProject()->url($document->getProject()->config('phpdoc.document_slug'), $document->getRef()->getName()));
        });

        // If the current document is the PHPDoc document viewer, add the required assets and add the proper init script
        $this->hook('controller:document', function ($controller, Document $document) {
            if (
                $document->getPathName() !== $document->getProject()->config('phpdoc.document_slug')
                || false === $document->getProject()->config('phpdoc.enabled', false)
            ) {
                return;
            }
            $this->codex()->theme
                ->addJavascript('jstree', asset('/vendor/codex/vendor/jstree/jstree.js'), [ 'jquery' ])
                ->addStylesheet('codex.page.phpdoc', asset('/vendor/codex/styles/codex.page.phpdoc.css'), [ 'codex' ]);
        });
    }
1017915
public static function bootstrap()
    {
        on('install',        'Pyrite\Users::install');
        on('user_fromemail', 'Pyrite\Users::fromEmail');
        on('user_resolve',   'Pyrite\Users::resolve');
        on('authenticate',   'Pyrite\Users::login');
        on('user_update',    'Pyrite\Users::update');
        on('user_create',    'Pyrite\Users::create');
        on('user_search',    'Pyrite\Users::search');
        on('ban_user',       'Pyrite\Users::ban');
        on('unban_user',     'Pyrite\Users::unban');
        on('clean_userids',  'Pyrite\Users::cleanList');
        on('all_users',      'Pyrite\Users::listAll');
    }
183895
protected function bootstrap()
    {
        $this->make('Sun\Bootstrap\Application')->bootstrap();

        $this->make('Sun\Bootstrap\HandleExceptions')->bootstrap();

        $this->make('Sun\Bootstrap\Route')->bootstrap();

        $this->make('Sun\Bootstrap\Provider')->bootstrap();

        $this->route = $this->make('Sun\Contracts\Routing\Route');
    }
704735
public function bootstrap()
    {
        $this->_startErrorHandler();

        $routesFile = "routes.php";
        $bootstrap = "bootstrap.php";

        $router = $this->getRouter();

        $event = new Bootstrap([
            'router' => $router,
            'application' => $this
        ]);
        $this->getEventManager()
            ->trigger(Bootstrap::BEFORE_BOOTSTRAP, $this, $event);

        Template::addPath(
            getcwd() .'/'. $this->getConfiguration()
                ->get('paths.views', 'Views')
        );

        Template::appendPath(__DIR__ . '/Views');

        foreach (Configuration::getPathList() as $path) {
            if (is_file("{$path}/{$bootstrap}")) {
                include("{$path}/{$bootstrap}");
            }

            if (is_file("{$path}/{$routesFile}")) {
                include("{$path}/{$routesFile}");
            }
        }
        $this->getEventManager()
            ->trigger(Bootstrap::AFTER_BOOTSTRAP, $this, $event);
    }
32548
public function boot()
    {
        PresetCommand::macro('uikit', function ($command) {
            UIkitPreset::install();
            $command->info('UIkit 3 scaffolding installed successfully.');
            $command->info('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
        });

        PresetCommand::macro('uikit-auth', function ($command) {
            UIkitPreset::installAuth();
            $command->info('UIkit 3 scaffolding with auth views installed successfully.');
            $command->info('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
        });
    }
976158
public static function boot()
    {
        parent::boot();

        self::creating(function ($invite) {
            if (!$invite->code) {
                $invite->code = Str::random(20);
            }
        });
    }