diff --git a/Neos.Flow/Classes/ObjectManagement/Proxy/Compiler.php b/Neos.Flow/Classes/ObjectManagement/Proxy/Compiler.php index 2abdca4190..3d15b3fc1a 100644 --- a/Neos.Flow/Classes/ObjectManagement/Proxy/Compiler.php +++ b/Neos.Flow/Classes/ObjectManagement/Proxy/Compiler.php @@ -15,6 +15,7 @@ use Neos\Flow\Annotations as Flow; use Neos\Flow\ObjectManagement\CompileTimeObjectManager; use Neos\Flow\Reflection\ReflectionService; +use Neos\Flow\SignalSlot\Dispatcher as SignalSlotDispatcher; use Neos\Flow\Tests\BaseTestCase; /** @@ -46,6 +47,11 @@ class Compiler */ protected $reflectionService; + /** + * @var SignalSlotDispatcher + */ + private $signalSlotDispatcher; + /** * @var array */ @@ -110,6 +116,15 @@ public function injectReflectionService(ReflectionService $reflectionService) $this->reflectionService = $reflectionService; } + /** + * @param SignalSlotDispatcher $signalSlotDispatcher + * @return void + */ + public function injectSignalSlotDispatcher(SignalSlotDispatcher $signalSlotDispatcher) + { + $this->signalSlotDispatcher = $signalSlotDispatcher; + } + /** * Returns a proxy class object for the specified original class. * @@ -194,8 +209,9 @@ public function compile() $class = new \ReflectionClass($fullOriginalClassName); $classPathAndFilename = $class->getFileName(); $this->cacheOriginalClassFileAndProxyCode($fullOriginalClassName, $classPathAndFilename, $proxyClassCode); - $this->storedProxyClasses[str_replace('\\', '_', $fullOriginalClassName)] = true; - $compiledClasses[] = $fullOriginalClassName; + $cacheName = str_replace('\\', '_', $fullOriginalClassName); + $this->storedProxyClasses[$cacheName] = true; + $compiledClasses[$fullOriginalClassName] = ['path' => $classPathAndFilename, 'cacheName' => $cacheName]; } } else { if ($this->classesCache->has(str_replace('\\', '_', $fullOriginalClassName))) { @@ -204,7 +220,8 @@ public function compile() } } } - $this->emitCompiledClasses($compiledClasses); + $this->emitCompiledClasses2($compiledClasses); + $this->emitCompiledClasses(array_keys($compiledClasses)); return count($compiledClasses); } @@ -214,6 +231,12 @@ public function compile() */ public function emitCompiledClasses(array $classNames) { + // BROKEN! Remove with next major? Or fixing? + } + + public function emitCompiledClasses2(array $classNames) + { + $this->signalSlotDispatcher->dispatch(__CLASS__, 'compiledClasses2', [$classNames]); } /** diff --git a/Neos.Flow/Classes/Package.php b/Neos.Flow/Classes/Package.php index b157f5dbe8..9b1a0eca83 100644 --- a/Neos.Flow/Classes/Package.php +++ b/Neos.Flow/Classes/Package.php @@ -12,6 +12,7 @@ */ use Neos\Flow\Cache\AnnotationsCacheFlusher; +use Neos\Flow\Cache\CacheManager; use Neos\Flow\Configuration\Loader\AppendLoader; use Neos\Flow\Configuration\Source\YamlSource; use Neos\Flow\Core\Booting\Step; @@ -26,6 +27,7 @@ use Neos\Flow\Security\Authentication\TokenInterface; use Neos\Flow\Security\Context; use Neos\Flow\Security\Cryptography\PrecomposedHashProvider; +use Neos\Utility\Files; /** * The Flow Package @@ -157,9 +159,32 @@ public function boot(Core\Bootstrap $bootstrap) $dispatcher->connect(AuthenticationProviderManager::class, 'successfullyAuthenticated', Context::class, 'refreshRoles'); $dispatcher->connect(AuthenticationProviderManager::class, 'loggedOut', Context::class, 'refreshTokens'); + // Broken! The Signal is not dispatched $dispatcher->connect(Proxy\Compiler::class, 'compiledClasses', function (array $classNames) use ($bootstrap) { $annotationsCacheFlusher = $bootstrap->getObjectManager()->get(AnnotationsCacheFlusher::class); $annotationsCacheFlusher->flushConfigurationCachesByCompiledClass($classNames); }); + + $dispatcher->connect(Proxy\Compiler::class, 'compiledClasses2', function (array $compiledClasses) use ($bootstrap) { + if ($compiledClasses !== []) { + $cacheDirectory = $bootstrap->getEarlyInstance(CacheManager::class)->getCache('Flow_Object_Classes')->getBackend()?->getCacheDirectory(); + + $localRemoteMapContent = ''; + foreach ($compiledClasses as $data) { + $localRemoteMapContent .= sprintf( + "%s%s.php = %s\n", + $cacheDirectory, + $data['cacheName'], + $data['path'] + ); + } + + Files::createDirectoryRecursively(FLOW_PATH_ROOT . '.xdebug'); + file_put_contents( + FLOW_PATH_ROOT . '.xdebug/flow.map', + $localRemoteMapContent + ); + } + }); } }