Bootstraps Moskito PHP plugin

@param producerRegistry producer registry to use
@throws PHPPluginBootstrapException on invalid configuration
168092
void bootstrapPlugin(IProducerRegistry producerRegistry) throws PHPPluginBootstrapException {

        config.setConfigChangedNotifier(new ConfigChangedNotifierImpl());
        MappersRegistry mappersRegistry = new MappersRegistry();
        listener = new OnProducerDataReceivedListenerImpl(mappersRegistry, producerRegistry);

        for (MapperConfig mapperConfig : config.getMappers()) {

            try {

                mappersRegistry.registerMapper(
                        mapperConfig.getMapperId(),
                        ((Mapper) createInstance(mapperConfig.getMapperClass()))
                );

            } catch (ClassNotFoundException e) {
                throw new PHPPluginBootstrapException(
                        "Mapper class " + mapperConfig.getMapperClass() + " not found", e
                );
            } catch (NoSuchMethodException | IllegalAccessException e) {
                throw new PHPPluginBootstrapException(
                        "Mapper class must have default public constructor", e
                );
            } catch (InvocationTargetException e) {
                throw new PHPPluginBootstrapException(
                        "Mapper constructor throws exception", e
                );
            } catch (InstantiationException e) {
                throw new PHPPluginBootstrapException(
                        "Failed to instance mapper of class " + mapperConfig.getMapperClass(), e
                );
            } catch (ClassCastException e) {
                throw new PHPPluginBootstrapException(
                        "Class " + mapperConfig.getMapperClass() +
                                " is not instance of " + Mapper.class.getCanonicalName(), e
                );
            }

        }

        boolean enableConnectorsInitOnStartup
                = PROPERTY_TRUE_VALUE.equals(startupProperties.getProperty(PROPERTY_CONNECTORS_FORCE_ENABLED));

       configureConnectors(enableConnectorsInitOnStartup);

    }
1218380
public function registerPlugin($plugin, $pluginId = null)
    {
        if (!$pluginId) {
            $pluginId = $this->getIdentifier($plugin);
        }

        if (!$plugin) {
            return;
        }

        $pluginPath = $this->getPluginPath($plugin);
        $pluginNamespace = strtolower($pluginId);

        /*
         * Register language namespaces
         */
        $langPath = $pluginPath . '/lang';
        if (File::isDirectory($langPath)) {
            Lang::addNamespace($pluginNamespace, $langPath);
        }

        if ($plugin->disabled) {
            return;
        }

        /*
         * Register plugin class autoloaders
         */
        $autoloadPath = $pluginPath . '/vendor/autoload.php';
        if (File::isFile($autoloadPath)) {
            ComposerManager::instance()->autoload($pluginPath . '/vendor');
        }

        if (!self::$noInit || $plugin->elevated) {
            $plugin->register();
        }

        /*
         * Register configuration path
         */
        $configPath = $pluginPath . '/config';
        if (File::isDirectory($configPath)) {
            Config::package($pluginNamespace, $configPath, $pluginNamespace);
        }

        /*
         * Register views path
         */
        $viewsPath = $pluginPath . '/views';
        if (File::isDirectory($viewsPath)) {
            View::addNamespace($pluginNamespace, $viewsPath);
        }

        /*
         * Add init, if available
         */
        $initFile = $pluginPath . '/init.php';
        if (!self::$noInit && File::exists($initFile)) {
            require $initFile;
        }

        /*
         * Add routes, if available
         */
        $routesFile = $pluginPath . '/routes.php';
        if (File::exists($routesFile)) {
            require $routesFile;
        }
    }
537465
def prep_bootstrap(mpt):
    '''
    

    '''
    # Verify that the boostrap script is downloaded
    bs_ = __salt__['config.gather_bootstrap_script']()
    fpd_ = os.path.join(mpt, 'tmp', "{0}".format(
        uuid.uuid4()))
    if not os.path.exists(fpd_):
        os.makedirs(fpd_)
    os.chmod(fpd_, 0o700)
    fp_ = os.path.join(fpd_, os.path.basename(bs_))
    # Copy script into tmp
    shutil.copy(bs_, fp_)
    tmppath = fpd_.replace(mpt, '')
    return fp_, tmppath
520317
public function boot()
    {
        parent::boot();

        $this->publishConfig();
        $this->publishViews();
        $this->registerProvider(Providers\RouteServiceProvider::class);
    }
319638
public function loadPluginConfiguration(): void
	{
		if ($this->compiler->getPlugin(CoreDecoratorPlugin::PLUGIN_NAME) === null) {
			throw new InvalidStateException(sprintf('Plugin "%s" must be enabled', CoreDecoratorPlugin::class));
		}

		$builder = $this->getContainerBuilder();
		$config = $this->getConfig();
		$globalConfig = $this->compiler->getExtension()->getConfig();

		$builder->addDefinition($this->prefix('transformer.json'))
			->setFactory(JsonTransformer::class)
			->addSetup('setDebugMode', [$globalConfig['debug']])
			->addTag(ApiExtension::NEGOTIATION_TRANSFORMER_TAG, ['suffix' => 'json'])
			->setAutowired(false);

		$builder->addDefinition($this->prefix('transformer.csv'))
			->setFactory(CsvTransformer::class)
			->addSetup('setDebugMode', [$globalConfig['debug']])
			->addTag(ApiExtension::NEGOTIATION_TRANSFORMER_TAG, ['suffix' => 'csv'])
			->setAutowired(false);

		$builder->addDefinition($this->prefix('transformer.fallback'))
			->setFactory(JsonTransformer::class)
			->addSetup('setDebugMode', [$globalConfig['debug']])
			->addTag(ApiExtension::NEGOTIATION_TRANSFORMER_TAG, ['suffix' => '*', 'fallback' => true])
			->setAutowired(false);

		$builder->addDefinition($this->prefix('transformer.renderer'))
			->setFactory(RendererTransformer::class)
			->addSetup('setDebugMode', [$globalConfig['debug']])
			->addTag(ApiExtension::NEGOTIATION_TRANSFORMER_TAG, ['suffix' => '#'])
			->setAutowired(false);

		$builder->addDefinition($this->prefix('negotiation'))
			->setFactory(ContentNegotiation::class);

		$builder->addDefinition($this->prefix('negotiator.suffix'))
			->setFactory(SuffixNegotiator::class)
			->addTag(ApiExtension::NEGOTIATION_NEGOTIATOR_TAG, ['priority' => 100]);

		$builder->addDefinition($this->prefix('negotiator.default'))
			->setFactory(DefaultNegotiator::class)
			->addTag(ApiExtension::NEGOTIATION_NEGOTIATOR_TAG, ['priority' => 200]);

		$builder->addDefinition($this->prefix('negotiator.fallback'))
			->setFactory(FallbackNegotiator::class)
			->addTag(ApiExtension::NEGOTIATION_NEGOTIATOR_TAG, ['priority' => 300]);

		$builder->addDefinition($this->prefix('decorator.response'))
			->setFactory(ResponseEntityDecorator::class)
			->addTag(ApiExtension::CORE_DECORATOR_TAG, ['priority' => 500]);

		if ($config['unification'] === true) {
			$builder->removeDefinition($this->prefix('transformer.fallback'));
			$builder->removeDefinition($this->prefix('transformer.json'));

			$builder->addDefinition($this->prefix('transformer.fallback'))
				->setFactory(JsonUnifyTransformer::class)
				->addSetup('setDebugMode', [$globalConfig['debug']])
				->addTag(ApiExtension::NEGOTIATION_TRANSFORMER_TAG, ['suffix' => '*', 'fallback' => true])
				->setAutowired(false);
			$builder->addDefinition($this->prefix('transformer.json'))
				->setFactory(JsonUnifyTransformer::class)
				->addSetup('setDebugMode', [$globalConfig['debug']])
				->addTag(ApiExtension::NEGOTIATION_TRANSFORMER_TAG, ['suffix' => 'json'])
				->setAutowired(false);
		}
	}
822666
protected function _bootstrap()
    {
        if(!defined('_JEXEC'))
        {
            $_SERVER['HTTP_HOST']       = 'localhost';
            $_SERVER['HTTP_USER_AGENT'] = 'Composer';
            $_SERVER['REMOTE_ADDR']     = '127.0.0.1';

            define('_JEXEC', 1);
            define('DS', DIRECTORY_SEPARATOR);

            define('JPATH_BASE', realpath('.'));

            if (!file_exists(JPATH_BASE . '/includes/defines.php')) {
                throw new \RuntimeException('Could not find Joomla files. Make sure to run `composer install` from inside the root folder of your Joomla installation!');
            }

            require_once JPATH_BASE . '/includes/defines.php';

            require_once JPATH_BASE . '/includes/framework.php';
            require_once JPATH_LIBRARIES . '/import.php';

            require_once JPATH_LIBRARIES . '/cms.php';
        }

        if(!($this->_application instanceof Application))
        {
            $options = array(
                'root_user' => $this->_credentials['username'],
                'loglevel'  => $this->_verbosity
            );

            $this->_application = new Application($options);
            $this->_application->authenticate($this->_credentials);
        }
    }
434432
protected function bootstrap()
    {
        $this->app->bootstrap();

        if ($this->app instanceof PluginApplicationInterface) {
            $this->app->pluginBootstrap();
        }
    }
159360
public function boot(Bootstrap $bootstrap)
    {
        $dispatcher = $bootstrap->getSignalSlotDispatcher();
        $dispatcher->connect(PersistenceManager::class, 'allObjectsPersisted', NodeDataRepository::class, 'flushNodeRegistry');
        $dispatcher->connect(NodeDataRepository::class, 'repositoryObjectsPersisted', NodeDataRepository::class, 'flushNodeRegistry');
        $dispatcher->connect(Node::class, 'nodePathChanged', function () use ($bootstrap) {
            $contextFactory = $bootstrap->getObjectManager()->get(ContextFactoryInterface::class);
            /** @var Context $contextInstance */
            foreach ($contextFactory->getInstances() as $contextInstance) {
                $contextInstance->getFirstLevelNodeCache()->flush();
            }
        });

        $dispatcher->connect(ConfigurationManager::class, 'configurationManagerReady', function (ConfigurationManager $configurationManager) {
            $configurationManager->registerConfigurationType('NodeTypes', ConfigurationManager::CONFIGURATION_PROCESSING_TYPE_DEFAULT, true);
        });

        $context = $bootstrap->getContext();
        if (!$context->isProduction()) {
            $dispatcher->connect(Sequence::class, 'afterInvokeStep', function ($step) use ($bootstrap) {
                if ($step->getIdentifier() === 'neos.flow:systemfilemonitor') {
                    $nodeTypeConfigurationFileMonitor = FileMonitor::createFileMonitorAtBoot('ContentRepository_NodeTypesConfiguration', $bootstrap);
                    /** @var PackageManager $packageManager */
                    $packageManager = $bootstrap->getEarlyInstance(PackageManagerInterface::class);
                    foreach ($packageManager->getFlowPackages() as $packageKey => $package) {
                        if ($packageManager->isPackageFrozen($packageKey)) {
                            continue;
                        }
                        if (file_exists($package->getConfigurationPath())) {
                            $nodeTypeConfigurationFileMonitor->monitorDirectory($package->getConfigurationPath(), 'NodeTypes(\..+)\.yaml');
                        }
                    }

                    $nodeTypeConfigurationFileMonitor->monitorDirectory(FLOW_PATH_CONFIGURATION, 'NodeTypes(\..+)\.yaml');

                    $nodeTypeConfigurationFileMonitor->detectChanges();
                    $nodeTypeConfigurationFileMonitor->shutdownObject();
                }
            });
        }
    }
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);
    }
505228
public void bootStrap(String customClusterXml, String customStoresXml) {
        AbstractStoreClientFactory factory = (AbstractStoreClientFactory) this.storeFactory;
        this.store = factory.getRawStore(storeName, null, customStoresXml, customClusterXml, null);
    }
1021758
public static function initializeProxyClasses(Bootstrap $bootstrap)
    {
        $objectConfigurationCache = $bootstrap->getEarlyInstance(CacheManager::class)->getCache('Flow_Object_Configuration');
        if ($objectConfigurationCache->has('allCompiledCodeUpToDate') === true) {
            return;
        }

        $configurationManager = $bootstrap->getEarlyInstance(ConfigurationManager::class);
        $settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow');

        // The compile sub command will only be run if the code cache is completely empty:
        OpcodeCacheHelper::clearAllActive(FLOW_PATH_CONFIGURATION);
        OpcodeCacheHelper::clearAllActive(FLOW_PATH_DATA);
        self::executeCommand('neos.flow:core:compile', $settings);
        if (isset($settings['persistence']['doctrine']['enable']) && $settings['persistence']['doctrine']['enable'] === true) {
            self::compileDoctrineProxies($bootstrap);
        }

        // As the available proxy classes were already loaded earlier we need to refresh them if the proxies where recompiled.
        $proxyClassLoader = $bootstrap->getEarlyInstance(ProxyClassLoader::class);
        $proxyClassLoader->initializeAvailableProxyClasses($bootstrap->getContext());

        // Check if code was updated, if not something went wrong
        if ($objectConfigurationCache->has('allCompiledCodeUpToDate') === false) {
            if (DIRECTORY_SEPARATOR === '/') {
                $phpBinaryPathAndFilename = '"' . escapeshellcmd(Files::getUnixStylePath($settings['core']['phpBinaryPathAndFilename'])) . '"';
            } else {
                $phpBinaryPathAndFilename = escapeshellarg(Files::getUnixStylePath($settings['core']['phpBinaryPathAndFilename']));
            }
            $command = sprintf('%s -c %s -v', $phpBinaryPathAndFilename, escapeshellarg(php_ini_loaded_file()));
            exec($command, $output, $result);
            if ($result !== 0) {
                if (!file_exists($phpBinaryPathAndFilename)) {
                    throw new FlowException(sprintf('It seems like the PHP binary "%s" cannot be executed by Flow. Set the correct path to the PHP executable in Configuration/Settings.yaml, setting Neos.Flow.core.phpBinaryPathAndFilename.', $settings['core']['phpBinaryPathAndFilename']), 1315561483);
                }
                throw new FlowException(sprintf('It seems like the PHP binary "%s" cannot be executed by Flow. The command executed was "%s" and returned the following: %s', $settings['core']['phpBinaryPathAndFilename'], $command, PHP_EOL . implode(PHP_EOL, $output)), 1354704332);
            }
            echo PHP_EOL . 'Flow: The compile run failed. Please check the error output or system log for more information.' . PHP_EOL;
            exit(1);
        }
    }
1161597
public function bootstrapPlugins()
    {
        $plugins = (array) $this->config->get('plugins.loaded');
        $plugins = array_filter($plugins, 'class_exists');

        $this->events->onTag('plugins', function () use ($plugins) {
            foreach ($plugins as $plugin) {
                $this->container->addServiceProvider($plugin);
            }
        });
    }
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');
        }
    }
257332
public function boot(Bootstrap $bootstrap)
    {
        $dispatcher = $bootstrap->getSignalSlotDispatcher();

        $context = $bootstrap->getContext();
        if (!$context->isProduction()) {
            $dispatcher->connect(Sequence::class, 'afterInvokeStep', function ($step) use ($bootstrap, $dispatcher) {
                if ($step->getIdentifier() === 'neos.flow:systemfilemonitor') {
                    $templateFileMonitor = FileMonitor::createFileMonitorAtBoot('Sitegeist_Monocle_Fusion_Files', $bootstrap);
                    /**
                     * @var PackageManagerInterface $packageManager
                     */
                    $packageManager = $bootstrap->getEarlyInstance(PackageManagerInterface::class);

                    foreach ($packageManager->getAvailablePackages() as $packageKey => $package) {
                        //
                        // this is here to distinguish between flow and other packages
                        // in flow 5 we can check wether the packe is a FlowPackage instead
                        // @todo fix this after the support for neos 3.3 is dropped
                        //
                        if (method_exists($package, 'getResourcesPath')) {
                            $templatesPath = $package->getResourcesPath() . 'Private/Fusion';
                            if (is_dir($templatesPath)) {
                                $templateFileMonitor->monitorDirectory($templatesPath);
                            }
                        }
                    }

                    $templateFileMonitor->detectChanges();
                    $templateFileMonitor->shutdownObject();
                }
            });
        }

        $flushTemplates = function ($identifier, $changedFiles) use ($bootstrap) {
            if ($identifier !== 'Sitegeist_Monocle_Fusion_Files') {
                return;
            }

            if ($changedFiles === []) {
                return;
            }

            $templateCache = $bootstrap->getObjectManager()->get(CacheManager::class)->getCache('Sitegeist_Monocle_Fusion');
            $templateCache->flush();
        };
        $dispatcher->connect(FileMonitor::class, 'filesHaveChanged', $flushTemplates);
    }
437712
public static function registerServiceProvider($serviceProvider)
    {
        if (is_callable($serviceProvider)) {
            $serviceProvider = new CustomServiceProvider($serviceProvider);
        } elseif (!is_a($serviceProvider, ServiceProviderInterface::class, true)) {
            throw new BootstrapException(
                "Error registering service provider: $serviceProvider is not valid service provider."
            );
        }
        if (self::$container === null) {
            self::$serviceProviders[] = $serviceProvider;
        } else {
            /** @var ServiceProviderInterface $provider */
            $provider = new $serviceProvider;
            $provider->register(self::$container);
        }
    }
313985
public function bootstrap(PluginApplicationInterface $app)
    {
        parent::bootstrap($app);

        //Sets directories to be created and must be writable
        Configure::write('WRITABLE_DIRS', [
            LOGS,
            TMP,
            CACHE,
            CACHE . 'models',
            CACHE . 'persistent',
            CACHE . 'views',
            TMP . 'sessions',
            TMP . 'tests',
            WWW_ROOT . 'files',
            WWW_ROOT . 'vendor',
        ]);

        //Sets symbolic links for vendor assets to be created
        Configure::write('VENDOR_LINKS', [
            'eonasdan' . DS . 'bootstrap-datetimepicker' . DS . 'build' => 'bootstrap-datetimepicker',
            'components' . DS . 'jquery' => 'jquery',
            'components' . DS . 'moment' . DS . 'min' => 'moment',
            'newerton' . DS . 'fancy-box' . DS . 'source' => 'fancybox',
            'npm-asset' . DS . 'fortawesome--fontawesome-free' => 'font-awesome',
            'twbs' . DS . 'bootstrap' . DS . 'dist' => 'bootstrap',
        ]);

        if (class_exists(Assets::class) && !$app->getPlugins()->has('Assets')) {
            $plugin = new Assets;
            $plugin->bootstrap($app);
            $app->addPlugin($plugin);
        }
    }
1121764
public function boot(Bootstrap $bootstrap)
    {
        $dispatcher = $bootstrap->getSignalSlotDispatcher();
        $package = $this;
        $dispatcher->connect(Sequence::class, 'afterInvokeStep', function (Step $step) use ($package, $bootstrap) {
            if ($step->getIdentifier() === 'neos.flow:objectmanagement:runtime') {
                $package->prepareRealtimeIndexing($bootstrap);
            }
        });
    }