/** * Flush all caches * * The flush command flushes all caches (including code caches) which have been * registered with Flow's Cache Manager. It also removes any session data. * * If fatal errors caused by a package prevent the compile time bootstrap * from running, the removal of any temporary data can be forced by specifying * the option <b>--force</b>. * * This command does not remove the precompiled data provided by frozen * packages unless the <b>--force</b> option is used. * * @param boolean $force Force flushing of any temporary data * @return void * @see typo3.flow:cache:warmup * @see typo3.flow:package:freeze * @see typo3.flow:package:refreeze */ public function flushCommand($force = FALSE) { // Internal note: the $force option is evaluated early in the Flow // bootstrap in order to reliably flush the temporary data before any // other code can cause fatal errors. $this->cacheManager->flushCaches(); $dataTemporaryPath = $this->environment->getPathToTemporaryDirectory(); \TYPO3\Flow\Utility\Files::unlink($dataTemporaryPath . 'AvailableProxyClasses.php'); $this->outputLine('Flushed all caches for "' . $this->bootstrap->getContext() . '" context.'); if ($this->lockManager->isSiteLocked()) { $this->lockManager->unlockSite(); } $frozenPackages = array(); foreach (array_keys($this->packageManager->getActivePackages()) as $packageKey) { if ($this->packageManager->isPackageFrozen($packageKey)) { $frozenPackages[] = $packageKey; } } if ($frozenPackages !== array()) { $this->outputFormatted(PHP_EOL . 'Please note that the following package' . (count($frozenPackages) === 1 ? ' is' : 's are') . ' currently frozen: ' . PHP_EOL); $this->outputFormatted(implode(PHP_EOL, $frozenPackages) . PHP_EOL, array(), 2); $message = 'As code and configuration changes in these packages are not detected, the application may respond '; $message .= 'unexpectedly if modifications were done anyway or the remaining code relies on these changes.' . PHP_EOL . PHP_EOL; $message .= 'You may call <b>package:refreeze all</b> in order to refresh frozen packages or use the <b>--force</b> '; $message .= 'option of this <b>cache:flush</b> command to flush caches if Flow becomes unresponsive.' . PHP_EOL; $this->outputFormatted($message, array($frozenPackages)); } $this->sendAndExit(0); }
/** * Invokes custom PHP code directly after the package manager has been initialized. * * @param Bootstrap $bootstrap The current bootstrap * @return void */ public function boot(Bootstrap $bootstrap) { $dispatcher = $bootstrap->getSignalSlotDispatcher(); $context = $bootstrap->getContext(); if (!$context->isProduction()) { $dispatcher->connect('TYPO3\\Flow\\Core\\Booting\\Sequence', 'afterInvokeStep', function ($step) use($bootstrap, $dispatcher) { if ($step->getIdentifier() === 'typo3.flow:systemfilemonitor') { $typoScriptFileMonitor = \TYPO3\Flow\Monitor\FileMonitor::createFileMonitorAtBoot('TypoScript_Files', $bootstrap); $packageManager = $bootstrap->getEarlyInstance('TYPO3\\Flow\\Package\\PackageManagerInterface'); foreach ($packageManager->getActivePackages() as $packageKey => $package) { if ($packageManager->isPackageFrozen($packageKey)) { continue; } $typoScriptPaths = array($package->getResourcesPath() . 'Private/TypoScript', $package->getResourcesPath() . 'Private/TypoScripts'); foreach ($typoScriptPaths as $typoScriptPath) { if (is_dir($typoScriptPath)) { $typoScriptFileMonitor->monitorDirectory($typoScriptPath); } } } $typoScriptFileMonitor->detectChanges(); $typoScriptFileMonitor->shutdownObject(); } if ($step->getIdentifier() === 'typo3.flow:cachemanagement') { $cacheManager = $bootstrap->getEarlyInstance('TYPO3\\Flow\\Cache\\CacheManager'); $listener = new \TYPO3\TypoScript\Core\Cache\FileMonitorListener($cacheManager); $dispatcher->connect('TYPO3\\Flow\\Monitor\\FileMonitor', 'filesHaveChanged', $listener, 'flushContentCacheOnFileChanges'); } }); } }
/** * Tells if a package is frozen * * @param string $packageKey The package to check * @return boolean */ public function isPackageFrozen($packageKey) { if (!isset($this->packages[$packageKey])) { return false; } $composerName = $this->packages[$packageKey]->getComposerName(); return $this->bootstrap->getContext()->isDevelopment() && isset($this->packageStatesConfiguration['packages'][$composerName]['frozen']) && $this->packageStatesConfiguration['packages'][$composerName]['frozen'] === true; }
/** * Loads the states of available packages from the PackageStates.php file. * The result is stored in $this->packageStatesConfiguration. * * @return void */ protected function loadPackageStates() { $this->packageStatesConfiguration = file_exists($this->packageStatesPathAndFilename) ? include $this->packageStatesPathAndFilename : array(); if (!isset($this->packageStatesConfiguration['version']) || $this->packageStatesConfiguration['version'] < 5) { $this->packageStatesConfiguration = array(); } if ($this->packageStatesConfiguration === array() || !$this->bootstrap->getContext()->isProduction()) { $this->scanAvailablePackages(); } else { $this->registerPackagesFromConfiguration(); } }
/** * @return string */ public function render() { $configuration = array('window.T3Configuration = {};', 'window.T3Configuration.locale = "' . $this->defaultLocale . '";', 'window.T3Configuration.localeInclude = ' . json_encode($this->getXliffAsJsonUri()) . ';', 'window.T3Configuration.UserInterface = ' . json_encode($this->settings['userInterface']) . ';', 'window.T3Configuration.nodeTypes = {};', 'window.T3Configuration.nodeTypes.groups = ' . json_encode($this->getNodeTypeGroupsSettings()) . ';', 'window.T3Configuration.requirejs = {};', 'window.T3Configuration.neosStaticResourcesBaseUri = ' . json_encode($this->resourceManager->getPublicPackageResourceUri('TYPO3.Neos', '')) . ';', 'window.T3Configuration.requirejs.paths = ' . json_encode($this->getRequireJsPathMapping()) . ';', 'window.T3Configuration.maximumFileUploadSize = ' . $this->renderMaximumFileUploadSize()); $neosJavaScriptBasePath = $this->getStaticResourceWebBaseUri('resource://TYPO3.Neos/Public/JavaScript'); $configuration[] = 'window.T3Configuration.neosJavascriptBasePath = ' . json_encode($neosJavaScriptBasePath) . ';'; if ($this->backendAssetsUtility->shouldLoadMinifiedJavascript()) { $configuration[] = 'window.T3Configuration.neosJavascriptVersion = ' . json_encode($this->backendAssetsUtility->getJavascriptBuiltVersion()) . ';'; } if ($this->bootstrap->getContext()->isDevelopment()) { $configuration[] = 'window.T3Configuration.DevelopmentMode = true;'; } return implode("\n", $configuration); }
/** * @return void */ protected function displayHelpIndex() { $context = $this->bootstrap->getContext(); $this->outputLine('<b>TYPO3 Flow %s ("%s" context)</b>', array($this->packageManager->getPackage('TYPO3.Flow')->getPackageMetaData()->getVersion() ?: FLOW_VERSION_BRANCH, $context)); $this->outputLine('<i>usage: %s <command identifier></i>', array($this->getFlowInvocationString())); $this->outputLine(); $this->outputLine('The following commands are currently available:'); $this->displayShortHelpForCommands($this->commandManager->getAvailableCommands()); $this->outputLine('* = compile time command'); $this->outputLine(); $this->outputLine('See "%s help <commandidentifier>" for more information about a specific command.', array($this->getFlowInvocationString())); $this->outputLine(); }
/** * @return void */ protected function displayHelpIndex() { $context = $this->bootstrap->getContext(); $applicationPackage = $this->packageManager->getPackage($this->applicationPackageKey); $this->outputLine('<b>%s %s ("%s" context)</b>', array($applicationPackage->getComposerManifest('description'), $applicationPackage->getInstalledVersion() ?: 'dev', $context)); $this->outputLine('<i>usage: %s <command identifier></i>', array($this->getFlowInvocationString())); $this->outputLine(); $this->outputLine('The following commands are currently available:'); $this->displayShortHelpForCommands($this->commandManager->getAvailableCommands()); $this->outputLine('* = compile time command'); $this->outputLine(); $this->outputLine('See "%s help <commandidentifier>" for more information about a specific command.', array($this->getFlowInvocationString())); $this->outputLine(); }
/** * Launch sub process * * @return array The new sub process and its STDIN, STDOUT, STDERR pipes – or FALSE if an error occurred. * @throws \RuntimeException */ protected function launchSubProcess() { $systemCommand = 'FLOW_ROOTPATH=' . FLOW_PATH_ROOT . ' FLOW_PATH_TEMPORARY_BASE=' . FLOW_PATH_TEMPORARY_BASE . ' ' . 'FLOW_CONTEXT=' . $this->bootstrap->getContext() . ' ' . PHP_BINDIR . '/php -c ' . php_ini_loaded_file() . ' ' . FLOW_PATH_FLOW . 'Scripts/flow.php' . ' --start-slave'; $descriptorSpecification = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'a')); $subProcess = proc_open($systemCommand, $descriptorSpecification, $pipes); if (!is_resource($subProcess)) { throw new \RuntimeException('Could not execute sub process.'); } $read = array($pipes[1]); $write = null; $except = null; $readTimeout = 30; stream_select($read, $write, $except, $readTimeout); $subProcessStatus = proc_get_status($subProcess); return $subProcessStatus['running'] === true ? array($subProcess, $pipes) : false; }
/** * Flushes a particular cache by its identifier * * Given a cache identifier, this flushes just that one cache. To find * the cache identifiers, you can use the configuration:show command with * the type set to "Caches". * * Note that this does not have a force-flush option since it's not * meant to remove temporary code data, resulting into a broken state if * code files lack. * * @param string $identifier Cache identifier to flush cache for * @return void * @see typo3.flow:cache:flush * @see typo3.flow:configuration:show */ public function flushOneCommand($identifier) { if (!$this->cacheManager->hasCache($identifier)) { $this->outputLine('The cache "%s" does not exist.', array($identifier)); $cacheConfigurations = $this->cacheManager->getCacheConfigurations(); $shortestDistance = -1; foreach (array_keys($cacheConfigurations) as $existingIdentifier) { $distance = levenshtein($existingIdentifier, $identifier); if ($distance <= $shortestDistance || $shortestDistance < 0) { $shortestDistance = $distance; $closestIdentifier = $existingIdentifier; } } if (isset($closestIdentifier)) { $this->outputLine('Did you mean "%s"?', array($closestIdentifier)); } $this->quit(1); } $this->cacheManager->getCache($identifier)->flush(); $this->outputLine('Flushed "%s" cache for "%s" context.', array($identifier, $this->bootstrap->getContext())); $this->sendAndExit(0); }
/** * Refreeze a package * * Refreezes a currently frozen package: all precompiled information is removed * and file monitoring will consider the package exactly once, on the next * request. After that request, the package remains frozen again, just with the * updated data. * * By specifying <b>all</b> as a package key, all currently frozen packages are * refrozen (the default). * * @param string $packageKey Key of the package to refreeze, or 'all' * @return void * @see typo3.flow:package:freeze * @see typo3.flow:cache:flush */ public function refreezeCommand($packageKey = 'all') { if (!$this->bootstrap->getContext()->isDevelopment()) { $this->outputLine('Package freezing is only supported in Development context.'); $this->quit(3); } $packagesToRefreeze = []; if ($packageKey === 'all') { foreach (array_keys($this->packageManager->getAvailablePackages()) as $packageKey) { if ($this->packageManager->isPackageFrozen($packageKey)) { $packagesToRefreeze[] = $packageKey; } } if ($packagesToRefreeze === []) { $this->outputLine('Nothing to do, no packages were frozen.'); $this->quit(0); } } else { if ($packageKey === null) { $this->outputLine('You must specify a package to refreeze.'); $this->quit(1); } if (!$this->packageManager->isPackageAvailable($packageKey)) { $this->outputLine('Package "%s" is not available.', [$packageKey]); $this->quit(2); } if (!$this->packageManager->isPackageFrozen($packageKey)) { $this->outputLine('Package "%s" was not frozen.', [$packageKey]); $this->quit(0); } $packagesToRefreeze = [$packageKey]; } foreach ($packagesToRefreeze as $packageKey) { $this->packageManager->refreezePackage($packageKey); $this->outputLine('Refroze package "%s".', [$packageKey]); } Scripts::executeCommand('typo3.flow:cache:flush', $this->settings, false); $this->sendAndExit(0); }
/** * Sets up xhprof, some directories, the profiler and wires signals to slots. * * @param Bootstrap $bootstrap * @return void */ public function boot(Bootstrap $bootstrap) { if (($samplingRate = getenv('PHPPROFILER_SAMPLINGRATE')) !== FALSE) { $currentSampleValue = mt_rand() / mt_getrandmax(); if ($currentSampleValue > (double) $samplingRate) { return; } } $profiler = Profiler::getInstance(); $profiler->setConfigurationProvider(function () use($bootstrap) { $settings = $bootstrap->getEarlyInstance('TYPO3\\Flow\\Configuration\\ConfigurationManager')->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Sandstorm.PhpProfiler'); if (!file_exists($settings['plumber']['profilePath'])) { Files::createDirectoryRecursively($settings['plumber']['profilePath']); } return $settings; }); $run = $profiler->start(); $run->setOption('Context', (string) $bootstrap->getContext()); $dispatcher = $bootstrap->getSignalSlotDispatcher(); $this->connectToSignals($dispatcher, $profiler, $run, $bootstrap); $this->connectToNeosSignals($dispatcher, $profiler, $run, $bootstrap); }
/** * Invokes custom PHP code directly after the package manager has been initialized. * * @param Bootstrap $bootstrap The current bootstrap * @return void */ public function boot(Bootstrap $bootstrap) { $dispatcher = $bootstrap->getSignalSlotDispatcher(); $context = $bootstrap->getContext(); if (!$context->isProduction()) { $dispatcher->connect('TYPO3\\Flow\\Core\\Booting\\Sequence', 'afterInvokeStep', function ($step) use($bootstrap, $dispatcher) { if ($step->getIdentifier() === 'typo3.flow:systemfilemonitor') { $templateFileMonitor = \TYPO3\Flow\Monitor\FileMonitor::createFileMonitorAtBoot('Fluid_TemplateFiles', $bootstrap); $packageManager = $bootstrap->getEarlyInstance('TYPO3\\Flow\\Package\\PackageManagerInterface'); foreach ($packageManager->getActivePackages() as $packageKey => $package) { if ($packageManager->isPackageFrozen($packageKey)) { continue; } foreach (array('Templates', 'Partials', 'Layouts') as $path) { $templatesPath = $package->getResourcesPath() . 'Private/' . $path; if (is_dir($templatesPath)) { $templateFileMonitor->monitorDirectory($templatesPath); } } } $templateFileMonitor->detectChanges(); $templateFileMonitor->shutdownObject(); } }); } // Use a closure to invoke the TemplateCompiler, since the object is not registered during compiletime $flushTemplates = function ($identifier, $changedFiles) use($bootstrap) { if ($identifier !== 'Flow_ClassFiles') { return; } $objectManager = $bootstrap->getObjectManager(); if ($objectManager->isRegistered('TYPO3\\Fluid\\Core\\Compiler\\TemplateCompiler')) { $templateCompiler = $objectManager->get('TYPO3\\Fluid\\Core\\Compiler\\TemplateCompiler'); $templateCompiler->flushTemplatesOnViewHelperChanges($changedFiles); } }; $dispatcher->connect('TYPO3\\Flow\\Monitor\\FileMonitor', 'filesHaveChanged', $flushTemplates); }
/** * Invokes custom PHP code directly after the package manager has been initialized. * * @param Core\Bootstrap $bootstrap The current bootstrap * @return void */ public function boot(Core\Bootstrap $bootstrap) { $bootstrap->registerRequestHandler(new Cli\SlaveRequestHandler($bootstrap)); $bootstrap->registerRequestHandler(new Cli\CommandRequestHandler($bootstrap)); $bootstrap->registerRequestHandler(new Http\RequestHandler($bootstrap)); if ($bootstrap->getContext()->isTesting()) { $bootstrap->registerRequestHandler(new Tests\FunctionalTestRequestHandler($bootstrap)); } $bootstrap->registerCompiletimeCommand('typo3.flow:core:*'); $bootstrap->registerCompiletimeCommand('typo3.flow:cache:flush'); $dispatcher = $bootstrap->getSignalSlotDispatcher(); $dispatcher->connect('TYPO3\\Flow\\Mvc\\Dispatcher', 'afterControllerInvocation', function ($request) use($bootstrap) { if (!$request instanceof Mvc\ActionRequest || $request->getHttpRequest()->isMethodSafe() !== TRUE) { $bootstrap->getObjectManager()->get('TYPO3\\Flow\\Persistence\\PersistenceManagerInterface')->persistAll(); } elseif ($request->getHttpRequest()->isMethodSafe()) { $bootstrap->getObjectManager()->get('TYPO3\\Flow\\Persistence\\PersistenceManagerInterface')->persistAll(TRUE); } }); $dispatcher->connect('TYPO3\\Flow\\Cli\\SlaveRequestHandler', 'dispatchedCommandLineSlaveRequest', 'TYPO3\\Flow\\Persistence\\PersistenceManagerInterface', 'persistAll'); $dispatcher->connect('TYPO3\\Flow\\Core\\Bootstrap', 'bootstrapShuttingDown', 'TYPO3\\Flow\\Configuration\\ConfigurationManager', 'shutdown'); $dispatcher->connect('TYPO3\\Flow\\Core\\Bootstrap', 'bootstrapShuttingDown', 'TYPO3\\Flow\\Object\\ObjectManagerInterface', 'shutdown'); $dispatcher->connect('TYPO3\\Flow\\Core\\Bootstrap', 'bootstrapShuttingDown', 'TYPO3\\Flow\\Reflection\\ReflectionService', 'saveToCache'); $dispatcher->connect('TYPO3\\Flow\\Command\\CoreCommandController', 'finishedCompilationRun', 'TYPO3\\Flow\\Security\\Policy\\PolicyService', 'savePolicyCache'); $dispatcher->connect('TYPO3\\Flow\\Command\\DoctrineCommandController', 'afterDatabaseMigration', 'TYPO3\\Flow\\Security\\Policy\\PolicyService', 'initializeRolesFromPolicy'); $dispatcher->connect('TYPO3\\Flow\\Security\\Authentication\\AuthenticationProviderManager', 'authenticatedToken', function () use($bootstrap) { $session = $bootstrap->getObjectManager()->get('TYPO3\\Flow\\Session\\SessionInterface'); if ($session->isStarted()) { $session->renewId(); } }); $dispatcher->connect('TYPO3\\Flow\\Monitor\\FileMonitor', 'filesHaveChanged', 'TYPO3\\Flow\\Cache\\CacheManager', 'flushSystemCachesByChangedFiles'); $dispatcher->connect('TYPO3\\Flow\\Tests\\FunctionalTestCase', 'functionalTestTearDown', 'TYPO3\\Flow\\Mvc\\Routing\\RouterCachingService', 'flushCaches'); $dispatcher->connect('TYPO3\\Flow\\Configuration\\ConfigurationManager', 'configurationManagerReady', function (Configuration\ConfigurationManager $configurationManager) { $configurationManager->registerConfigurationType('Views', Configuration\ConfigurationManager::CONFIGURATION_PROCESSING_TYPE_APPEND); }); $dispatcher->connect('TYPO3\\Flow\\Command\\CacheCommandController', 'warmupCaches', 'TYPO3\\Flow\\Configuration\\ConfigurationManager', 'warmup'); }
/** * Invokes custom PHP code directly after the package manager has been initialized. * * @param \TYPO3\Flow\Core\Bootstrap $bootstrap The current bootstrap * @return void */ public function boot(\TYPO3\Flow\Core\Bootstrap $bootstrap) { $dispatcher = $bootstrap->getSignalSlotDispatcher(); $dispatcher->connect('TYPO3\\Flow\\Persistence\\Doctrine\\PersistenceManager', 'allObjectsPersisted', 'TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository', 'flushNodeRegistry'); $dispatcher->connect('TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository', 'repositoryObjectsPersisted', 'TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository', 'flushNodeRegistry'); $dispatcher->connect('TYPO3\\TYPO3CR\\Domain\\Model\\Node', 'nodePathChanged', function () use($bootstrap) { $contextFactory = $bootstrap->getObjectManager()->get('TYPO3\\TYPO3CR\\Domain\\Service\\ContextFactoryInterface'); /** @var Context $contextInstance */ foreach ($contextFactory->getInstances() as $contextInstance) { $contextInstance->getFirstLevelNodeCache()->flush(); } }); $dispatcher->connect('TYPO3\\Flow\\Configuration\\ConfigurationManager', 'configurationManagerReady', function (ConfigurationManager $configurationManager) { $configurationManager->registerConfigurationType('NodeTypes', ConfigurationManager::CONFIGURATION_PROCESSING_TYPE_DEFAULT, true); }); $context = $bootstrap->getContext(); if (!$context->isProduction()) { $dispatcher->connect('TYPO3\\Flow\\Core\\Booting\\Sequence', 'afterInvokeStep', function ($step) use($bootstrap) { if ($step->getIdentifier() === 'typo3.flow:systemfilemonitor') { $nodeTypeConfigurationFileMonitor = \TYPO3\Flow\Monitor\FileMonitor::createFileMonitorAtBoot('TYPO3CR_NodeTypesConfiguration', $bootstrap); $packageManager = $bootstrap->getEarlyInstance('TYPO3\\Flow\\Package\\PackageManagerInterface'); foreach ($packageManager->getActivePackages() 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(); } }); } }
/** * Flushes a particular cache by its identifier * * Given a cache identifier, this flushes just that one cache. To find * the cache identifiers, you can use the configuration:show command with * the type set to "Caches". * * Note that this does not have a force-flush option since it's not * meant to remove temporary code data, resulting into a broken state if * code files lack. * * @param string $identifier Cache identifier to flush cache for * @return void * @see typo3.flow:cache:flush * @see typo3.flow:configuration:show */ public function flushOneCommand($identifier) { $this->cacheManager->getCache($identifier)->flush(); $this->outputLine('Flushed "%s" cache for "%s" context.', array($identifier, $this->bootstrap->getContext())); $this->sendAndExit(0); }
/** * Initializes the runtime Object Manager * * @param Bootstrap $bootstrap * @return void */ 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()); Bootstrap::$staticObjectManager = $objectManager; $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); }
/** * Initializes the runtime Object Manager * * @param Bootstrap $bootstrap * @return void */ public static function initializeObjectManager(Bootstrap $bootstrap) { $configurationManager = $bootstrap->getEarlyInstance('TYPO3\\Flow\\Configuration\\ConfigurationManager'); $objectConfigurationCache = $bootstrap->getEarlyInstance('TYPO3\\Flow\\Cache\\CacheManager')->getCache('Flow_Object_Configuration'); $objectManager = new \TYPO3\Flow\Object\ObjectManager($bootstrap->getContext()); Bootstrap::$staticObjectManager = $objectManager; $objectManager->injectAllSettings($configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS)); $objectManager->setObjects($objectConfigurationCache->get('objects')); foreach ($bootstrap->getEarlyInstances() as $objectName => $instance) { $objectManager->setInstance($objectName, $instance); } $objectManager->get('TYPO3\\Flow\\SignalSlot\\Dispatcher')->injectObjectManager($objectManager); \TYPO3\Flow\Error\Debugger::injectObjectManager($objectManager); $bootstrap->setEarlyInstance('TYPO3\\Flow\\Object\\ObjectManagerInterface', $objectManager); }
/** * This request handler can handle CLI requests. * * @return boolean If the request is a CLI request, TRUE otherwise FALSE */ public function canHandleRequest() { return $this->bootstrap->getContext()->isTesting(); }
/** * Invokes custom PHP code directly after the package manager has been initialized. * * @param Core\Bootstrap $bootstrap The current bootstrap * @return void */ public function boot(Core\Bootstrap $bootstrap) { $bootstrap->registerRequestHandler(new Cli\SlaveRequestHandler($bootstrap)); $bootstrap->registerRequestHandler(new Cli\CommandRequestHandler($bootstrap)); $bootstrap->registerRequestHandler(new Http\RequestHandler($bootstrap)); if ($bootstrap->getContext()->isTesting()) { $bootstrap->registerRequestHandler(new Tests\FunctionalTestRequestHandler($bootstrap)); } $bootstrap->registerCompiletimeCommand('typo3.flow:core:*'); $bootstrap->registerCompiletimeCommand('typo3.flow:cache:flush'); $dispatcher = $bootstrap->getSignalSlotDispatcher(); $dispatcher->connect(\TYPO3\Flow\Mvc\Dispatcher::class, 'afterControllerInvocation', function ($request) use($bootstrap) { if ($bootstrap->getObjectManager()->hasInstance(\TYPO3\Flow\Persistence\PersistenceManagerInterface::class)) { if (!$request instanceof Mvc\ActionRequest || $request->getHttpRequest()->isMethodSafe() !== true) { $bootstrap->getObjectManager()->get(\TYPO3\Flow\Persistence\PersistenceManagerInterface::class)->persistAll(); } elseif ($request->getHttpRequest()->isMethodSafe()) { $bootstrap->getObjectManager()->get(\TYPO3\Flow\Persistence\PersistenceManagerInterface::class)->persistAll(true); } } }); $dispatcher->connect(\TYPO3\Flow\Cli\SlaveRequestHandler::class, 'dispatchedCommandLineSlaveRequest', \TYPO3\Flow\Persistence\PersistenceManagerInterface::class, 'persistAll'); $context = $bootstrap->getContext(); if (!$context->isProduction()) { $dispatcher->connect(\TYPO3\Flow\Core\Booting\Sequence::class, 'afterInvokeStep', function ($step) use($bootstrap, $dispatcher) { if ($step->getIdentifier() === 'typo3.flow:resources') { $publicResourcesFileMonitor = \TYPO3\Flow\Monitor\FileMonitor::createFileMonitorAtBoot('Flow_PublicResourcesFiles', $bootstrap); $packageManager = $bootstrap->getEarlyInstance(\TYPO3\Flow\Package\PackageManagerInterface::class); foreach ($packageManager->getActivePackages() 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, $changedFiles) use($bootstrap) { if ($identifier !== 'Flow_PublicResourcesFiles') { return; } $objectManager = $bootstrap->getObjectManager(); $resourceManager = $objectManager->get(\TYPO3\Flow\Resource\ResourceManager::class); $resourceManager->getCollection(ResourceManager::DEFAULT_STATIC_COLLECTION_NAME)->publish(); }; $dispatcher->connect(\TYPO3\Flow\Monitor\FileMonitor::class, 'filesHaveChanged', $publishResources); $dispatcher->connect(\TYPO3\Flow\Core\Bootstrap::class, 'bootstrapShuttingDown', \TYPO3\Flow\Configuration\ConfigurationManager::class, 'shutdown'); $dispatcher->connect(\TYPO3\Flow\Core\Bootstrap::class, 'bootstrapShuttingDown', \TYPO3\Flow\Object\ObjectManagerInterface::class, 'shutdown'); $dispatcher->connect(\TYPO3\Flow\Core\Bootstrap::class, 'bootstrapShuttingDown', \TYPO3\Flow\Reflection\ReflectionService::class, 'saveToCache'); $dispatcher->connect(\TYPO3\Flow\Command\CoreCommandController::class, 'finishedCompilationRun', \TYPO3\Flow\Security\Authorization\Privilege\Method\MethodPrivilegePointcutFilter::class, 'savePolicyCache'); $dispatcher->connect(\TYPO3\Flow\Command\CoreCommandController::class, 'finishedCompilationRun', \TYPO3\Flow\Aop\Pointcut\RuntimeExpressionEvaluator::class, 'saveRuntimeExpressions'); $dispatcher->connect(\TYPO3\Flow\Security\Authentication\AuthenticationProviderManager::class, 'authenticatedToken', function () use($bootstrap) { $session = $bootstrap->getObjectManager()->get(\TYPO3\Flow\Session\SessionInterface::class); if ($session->isStarted()) { $session->renewId(); } }); $dispatcher->connect(\TYPO3\Flow\Monitor\FileMonitor::class, 'filesHaveChanged', \TYPO3\Flow\Cache\CacheManager::class, 'flushSystemCachesByChangedFiles'); $dispatcher->connect(\TYPO3\Flow\Tests\FunctionalTestCase::class, 'functionalTestTearDown', \TYPO3\Flow\Mvc\Routing\RouterCachingService::class, 'flushCaches'); $dispatcher->connect(\TYPO3\Flow\Configuration\ConfigurationManager::class, 'configurationManagerReady', function (Configuration\ConfigurationManager $configurationManager) { $configurationManager->registerConfigurationType('Views', Configuration\ConfigurationManager::CONFIGURATION_PROCESSING_TYPE_APPEND); }); $dispatcher->connect(\TYPO3\Flow\Command\CacheCommandController::class, 'warmupCaches', \TYPO3\Flow\Configuration\ConfigurationManager::class, 'warmup'); $dispatcher->connect(\TYPO3\Fluid\Core\Parser\TemplateParser::class, 'initializeNamespaces', function (TemplateParser $templateParser) use($bootstrap) { /** @var PackageManagerInterface $packageManager */ $packageManager = $bootstrap->getEarlyInstance(\TYPO3\Flow\Package\PackageManagerInterface::class); /** @var PackageInterface $package */ foreach ($packageManager->getActivePackages() as $package) { $templateParser->registerNamespace(strtolower($package->getPackageKey()), $package->getNamespace() . '\\ViewHelpers'); } }); $dispatcher->connect(\TYPO3\Flow\Package\PackageManager::class, 'packageStatesUpdated', function () use($dispatcher) { $dispatcher->connect(\TYPO3\Flow\Core\Bootstrap::class, 'bootstrapShuttingDown', \TYPO3\Flow\Cache\CacheManager::class, 'flushCaches'); }); }