<commit_before><?php
namespace Neos\Flow;

/*
 * This file is part of the Neos.Flow package.
 *
 * (c) Contributors of the Neos Project - www.neos.io
 *
 * This package is Open Source Software. For the full copyright and license
 * information, please view the LICENSE file which was distributed with this
 * source code.
 */

use Neos\Flow\Package\Package as BasePackage;
use Neos\Flow\ResourceManagement\ResourceManager;

/**
 * The Flow Package
 */
class Package extends BasePackage
{
    /**
     * @var boolean
     */
    protected $protected = true;

    /**
     * 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('neos.flow:core:*');
        $bootstrap->registerCompiletimeCommand('neos.flow:cache:flush');
        $bootstrap->registerCompiletimeCommand('neos.flow:package:rescan');

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

        $context = $bootstrap->getContext();
        if (!$context->isProduction()) {
            $dispatcher->connect(\Neos\Flow\Core\Booting\Sequence::class, 'afterInvokeStep', function ($step) use ($bootstrap, $dispatcher) {
                if ($step->getIdentifier() === 'neos.flow:resources') {
                    $publicResourcesFileMonitor = \Neos\Flow\Monitor\FileMonitor::createFileMonitorAtBoot('Flow_PublicResourcesFiles', $bootstrap);
                    $packageManager = $bootstrap->getEarlyInstance(\Neos\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(\Neos\Flow\ResourceManagement\ResourceManager::class);
            $resourceManager->getCollection(ResourceManager::DEFAULT_STATIC_COLLECTION_NAME)->publish();
        };

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

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

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

        $dispatcher->connect(\Neos\Flow\Command\CoreCommandController::class, 'finishedCompilationRun', \Neos\Flow\Security\Authorization\Privilege\Method\MethodPrivilegePointcutFilter::class, 'savePolicyCache');
        $dispatcher->connect(\Neos\Flow\Command\CoreCommandController::class, 'finishedCompilationRun', \Neos\Flow\Aop\Pointcut\RuntimeExpressionEvaluator::class, 'saveRuntimeExpressions');

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

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

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

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

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

        $dispatcher->connect(\Neos\Flow\Persistence\Doctrine\EntityManagerFactory::class, 'beforeDoctrineEntityManagerCreation', \Neos\Flow\Persistence\Doctrine\EntityManagerConfiguration::class, 'configureEntityManager');
        $dispatcher->connect(\Neos\Flow\Persistence\Doctrine\EntityManagerFactory::class, 'afterDoctrineEntityManagerCreation', \Neos\Flow\Persistence\Doctrine\EntityManagerConfiguration::class, 'enhanceEntityManager');
    }
}<commit_msg>TASK: Simplify FQN in Package.php for Flow<commit_after><?php
namespace Neos\Flow;

/*
 * This file is part of the Neos.Flow package.
 *
 * (c) Contributors of the Neos Project - www.neos.io
 *
 * This package is Open Source Software. For the full copyright and license
 * information, please view the LICENSE file which was distributed with this
 * source code.
 */

use Neos\Flow\Package\Package as BasePackage;
use Neos\Flow\ResourceManagement\ResourceManager;

/**
 * The Flow Package
 */
class Package extends BasePackage
{
    /**
     * @var boolean
     */
    protected $protected = true;

    /**
     * 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('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()->hasInstance(Persistence\PersistenceManagerInterface::class)) {
                if (!$request instanceof Mvc\ActionRequest || $request->getHttpRequest()->isMethodSafe() !== true) {
                    $bootstrap->getObjectManager()->get(Persistence\PersistenceManagerInterface::class)->persistAll();
                } elseif ($request->getHttpRequest()->isMethodSafe()) {
                    $bootstrap->getObjectManager()->get(Persistence\PersistenceManagerInterface::class)->persistAll(true);
                }
            }
        });
        $dispatcher->connect(Cli\SlaveRequestHandler::class, 'dispatchedCommandLineSlaveRequest', Persistence\PersistenceManagerInterface::class, 'persistAll');

        $context = $bootstrap->getContext();
        if (!$context->isProduction()) {
            $dispatcher->connect(Core\Booting\Sequence::class, 'afterInvokeStep', function ($step) use ($bootstrap, $dispatcher) {
                if ($step->getIdentifier() === 'neos.flow:resources') {
                    $publicResourcesFileMonitor = Monitor\FileMonitor::createFileMonitorAtBoot('Flow_PublicResourcesFiles', $bootstrap);
                    $packageManager = $bootstrap->getEarlyInstance(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(ResourceManager::class);
            $resourceManager->getCollection(ResourceManager::DEFAULT_STATIC_COLLECTION_NAME)->publish();
        };

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

        $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(Command\CoreCommandController::class, 'finishedCompilationRun', Aop\Pointcut\RuntimeExpressionEvaluator::class, 'saveRuntimeExpressions');

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

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

        $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');
    }
}
{'fraction_non_alphanumeric': 0.12826535696490854, 'fraction_numerical': 0.0, 'mean_word_length': 3.5381136950904395, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 129, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2713617', 'n_tokens_mistral': 3483, 'n_tokens_neox': 3381, 'n_words': 494}