Update Doctrine 2 proxy classes

This is not simply bound to the finishedCompilationRun signal because it
needs the advised proxy classes to run. When that signal is fired, they
have been written, but not loaded.

@param Bootstrap $bootstrap
@return void
435984
protected static function compileDoctrineProxies(Bootstrap $bootstrap)
    {
        $cacheManager = $bootstrap->getEarlyInstance(CacheManager::class);
        $objectConfigurationCache = $cacheManager->getCache('Flow_Object_Configuration');
        $coreCache = $cacheManager->getCache('Flow_Core');
        $configurationManager = $bootstrap->getEarlyInstance(ConfigurationManager::class);
        $settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow');

        if ($objectConfigurationCache->has('doctrineProxyCodeUpToDate') === false && $coreCache->has('doctrineSetupRunning') === false) {
            $logger = $bootstrap->getEarlyInstance(PsrLoggerFactoryInterface::class)->get('systemLogger');
            $coreCache->set('doctrineSetupRunning', 'White Russian', [], 60);
            $logger->debug('Compiling Doctrine proxies');
            self::executeCommand('neos.flow:doctrine:compileproxies', $settings);
            $coreCache->remove('doctrineSetupRunning');
            $objectConfigurationCache->set('doctrineProxyCodeUpToDate', true);
        }
    }
546253
public function setClassName($className)
    {
        try {
            $classFilename = ClassLoader::getInstance()->findClass($className);
            if (!file_exists($classFilename)) {
                throw new BootstrapException('The provided callback class "' . $className . '" does not exist.');
            } else {
                $this->className = $className;
            }
        } catch (\Exception $e) {
            throw $e;
        }
    }
865814
public function initialize(Bootstrap $bootstrap)
    {
        $this->bootstrap = $bootstrap;
        $this->packageStatesConfiguration = $this->getCurrentPackageStates();
        $this->registerPackagesFromConfiguration($this->packageStatesConfiguration);
        /** @var PackageInterface $package */

        foreach ($this->packages as $package) {
            if ($package instanceof FlowPackageInterface) {
                $this->flowPackages[$package->getPackageKey()] = $package;
            }
            if (!$package instanceof BootablePackageInterface) {
                continue;
            }
            $package->boot($bootstrap);
        }
    }
1140611
public static function initializeObjectManager(Bootstrap $bootstrap)
    {
        $configurationManager = $bootstrap->getEarlyInstance(ConfigurationManager::class);
        $objectConfigurationCache = $bootstrap->getEarlyInstance(CacheManager::class)->getCache('Flow_Object_Configuration');

        $objectManager = new ObjectManager($bootstrap->getContext());

        $objectManager->injectAllSettings($configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS));
        $objectManager->setObjects($objectConfigurationCache->get('objects'));

        foreach ($bootstrap->getEarlyInstances() as $objectName => $instance) {
            $objectManager->setInstance($objectName, $instance);
        }

        $objectManager->get(Dispatcher::class)->injectObjectManager($objectManager);
        Debugger::injectObjectManager($objectManager);
        $bootstrap->setEarlyInstance(ObjectManagerInterface::class, $objectManager);

        Bootstrap::$staticObjectManager = $objectManager;
    }
506322
public function bootstrapify() {		
		foreach($this->owner as $f) {

			$sng = Injector::inst()->get($f->class, true, ['dummy', '']);

			if(isset($this->ignores[$f->getName()])) continue;

            // if we have a CompositeField, bootstrapify its children
            if($f instanceof CompositeField) {
                $f->getChildren()->bootstrapify();
                continue;
            }

			// If we have a Tabset, bootstrapify all Tabs
			if($f instanceof TabSet) {
				$f->Tabs()->bootstrapify();
			}

			// If we have a Tab, bootstrapify all its Fields
			if($f instanceof Tab) {
				$f->Fields()->bootstrapify();
			}

			// If the user has customised the holder template already, don't apply the default one.
			if($sng->getFieldHolderTemplate() == $f->getFieldHolderTemplate()) {
				$template = "Bootstrap{$f->class}_holder";			
				if(SSViewer::hasTemplate($template)) {					
					$f->setFieldHolderTemplate($template);				
				}
				else {				
					$f->setFieldHolderTemplate("BootstrapFieldHolder");
				}

			}

			// If the user has customised the field template already, don't apply the default one.
			if($sng->getTemplate() == $f->getTemplate()) {
				foreach(array_reverse(ClassInfo::ancestry($f)) as $className) {						
					$bootstrapCandidate = "Bootstrap{$className}";
					$nativeCandidate = $className;
					if(SSViewer::hasTemplate($bootstrapCandidate)) {
						$f->setTemplate($bootstrapCandidate);
						break;
					}
					elseif(SSViewer::hasTemplate($nativeCandidate)) {
						$f->setTemplate($nativeCandidate);
						break;
					}


				}
			}
		}

		return $this->owner;		
	}
1355763
protected function bootstrapContainer()
    {
        static::setInstance($this);

        $this->instance('app', $this);
        $this->instance('Bugotech\Foundation\Application', $this);

        $this->registerContainerAliases();
        $this->registerBinders();
        $this->registerContainerBase();

        $this->configure('app');
        $this->configure('paths');
    }
1116003
protected function invokeBootstrap(string $bootstrapClass, MutableContainer $container)
    {
        $this->ensureBootstrap($bootstrapClass);

        (new $bootstrapClass($container, $this))();
    }
739555
public function bootstrap()
    {
        if(!$this->isBootstrapped())
        {
            $manager = $this->getObject('manager');

            /*
             * 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->_manifests as $manifest)
                {
                    if (isset($manifest['identifier']))
                    {
                        $identifier = $manifest['identifier'];

                        if (isset($this->_components[$identifier])) {
                            throw new \RuntimeException(sprintf('Cannot re-bootstrap component: %s', $identifier));
                        }

                        //Set the path
                        $this->_components[$identifier] = $manifest['paths'];

                        //Set the namespace
                        if (isset($manifest['namespace']))
                        {
                            $namespace = $manifest['namespace'];
                            $this->_namespaces[$identifier] = array($namespace => $manifest['paths']);
                        }
                    }
                }

                foreach($this->_manifests as  $manifest)
                {
                    if (isset($manifest['extends']))
                    {
                        $extends = $manifest['extends'];

                        if (!isset($this->_components[$extends])) {
                            throw new \RuntimeException(sprintf('Component: %s not found', $extends));
                        }

                        if(isset($manifest['identifier']))
                        {
                            $identifier = $manifest['identifier'];

                            //Append paths
                            $this->_components[$identifier] = array_merge(
                                $this->_components[$identifier],
                                $this->_components[$extends]
                            );

                            //Set the namespace
                            if (isset($manifest['namespace']))
                            {
                                $namespace = $manifest['namespace'];

                                //Append the namespace
                                $this->_namespaces[$identifier] = array_merge(
                                    $this->_namespaces[$identifier],
                                    $this->_namespaces[$extends]
                                );
                            }
                        }
                        else
                        {
                            //Prepend paths
                            $this->_components[$extends] = array_merge(
                                $manifest['paths'],
                                $this->_components[$extends]
                            );

                            //Set the namespace
                            if (isset($manifest['namespace']))
                            {
                                $namespace = $manifest['namespace'];

                                //Prepend the namespace
                                $this->_namespaces[$extends] = array_merge(
                                    array($namespace => $manifest['paths']),
                                    $this->_namespaces[$extends]
                                );
                            }
                        }
                    }
                }

                $identifiers = array();
                $aliases     = array();

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

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

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

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

                    //Identifiers
                    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 ObjectConfig($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();

                ksort($identifiers);
                foreach ($identifiers as $priority => $merges) {
                    $identifiers_flat = array_merge_recursive($identifiers_flat, $merges);
                }

                foreach ($identifiers_flat as $identifier => $config) {
                    $manager->setIdentifier(new ObjectIdentifier($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 ObjectIdentifier('lib:object.bootstrapper', array(
                    'bootstrapped' => true,
                    'directories'  => $this->_directories,
                    'components'   => $this->_components,
                    'namespaces'   => $this->_namespaces,
                    'files'        => $this->_files,
                    'aliases'      => $aliases_flat,
                ));

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

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

                //Register the namespace in the component objects locator
                $manager->getLocator('component')->registerIdentifier($identifier, array_keys($namespaces));
            }

            $this->_bootstrapped = true;
        }
    }
122707
protected function bootstrap($appBootstrap, $appenv, $debug)
    {
        if ($bridge = $this->getBridge()) {
            $bridge->bootstrap($appBootstrap, $appenv, $debug);
            $this->sendMessage($this->controller, 'ready');
        }
    }
723506
protected function bootstrap()
    {
        if($this->_isBooted) {
            return;
        }

        swoole_set_process_name($this->name . ':master');
        $this->installSignals();
        $this->_isBooted = true;
    }
627938
public function bootstrap(): void
    {
        foreach ($this->bootstrap as $mixed) {
            $component = null;
            if ($mixed instanceof \Closure) {
                $this->debug('Bootstrap with Closure', __METHOD__);
                if (empty($component = call_user_func($mixed, $this))) {
                    continue;
                }
            } elseif (is_string($mixed)) {
                if ($this->has($mixed)) {
                    $component = $this->get($mixed);
                } elseif ($this->hasModule($mixed)) {
                    $component = $this->getModule($mixed);
                } elseif (strpos($mixed, '\\') === false) {
                    throw new InvalidConfigException("Unknown bootstrapping component ID: $mixed");
                }
            }

            if (!isset($component)) {
                $component = $this->createObject($mixed);
            }

            if ($component instanceof BootstrapInterface) {
                $this->debug('Bootstrap with ' . get_class($component) . '::bootstrap()', __METHOD__);
                $component->bootstrap($this);
            } else {
                $this->debug('Bootstrap with ' . get_class($component), __METHOD__);
            }
        }
    }
623805
public static function initializeReflectionServiceFactory(Bootstrap $bootstrap)
    {
        $reflectionServiceFactory = new ReflectionServiceFactory($bootstrap);
        $bootstrap->setEarlyInstance(ReflectionServiceFactory::class, $reflectionServiceFactory);
        $bootstrap->getObjectManager()->setInstance(ReflectionServiceFactory::class, $reflectionServiceFactory);
    }
813842
public static function boot()
    {
        parent::boot();

        $class = get_called_class();

        if (method_exists($class, 'handleUniqueColumns')) {
            self::handleUniqueColumns();
        }

        if (static::$observer != null) {
            $class::observe(new static::$observer);
        }
    }
137872
public function boot(\Neos\Flow\Core\Bootstrap $bootstrap)
    {
        $bootstrap->registerRequestHandler(new \Neos\Setup\Core\RequestHandler($bootstrap));
    }
67826
protected function bootstrap()
    {
        foreach (static::$bootstrappers as $bootstrapper) {
            try{
                $bootstrapper($this);
            }catch (\Exception $e){
                echo $e->getMessage();
            }
        }
    }
456829
public function afterCompile(ClassType $class) : void
    {
        $initialize = $class->methods['initialize'];
        $initialize->addBody(\Wakers\Propel\Setup\PropelSetup::class . '::setup($this);');
    }
1080949
public static function forceFlushCachesIfNecessary(Bootstrap $bootstrap)
    {
        if (!isset($_SERVER['argv']) || !isset($_SERVER['argv'][1]) || !isset($_SERVER['argv'][2])
            || !in_array($_SERVER['argv'][1], ['neos.flow:cache:flush', 'flow:cache:flush'])
            || !in_array($_SERVER['argv'][2], ['--force', '-f'])) {
            return;
        }

        $bootstrap->getEarlyInstance(CacheManager::class)->flushCaches();
        $environment = $bootstrap->getEarlyInstance(Environment::class);
        Files::emptyDirectoryRecursively($environment->getPathToTemporaryDirectory());

        echo 'Force-flushed caches for "' . $bootstrap->getContext() . '" context.' . PHP_EOL;

        // In production the site will be locked as this is a compiletime request so we need to take care to remove that lock again.
        if ($bootstrap->getContext()->isProduction()) {
            $bootstrap->getEarlyInstance(CoreLockManager::class)->unlockSite();
        }

        exit(0);
    }