Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions Neos.Flow/Classes/ObjectManagement/Proxy/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -46,6 +47,11 @@ class Compiler
*/
protected $reflectionService;

/**
* @var SignalSlotDispatcher
*/
private $signalSlotDispatcher;

/**
* @var array
*/
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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))) {
Expand All @@ -204,7 +220,8 @@ public function compile()
}
}
}
$this->emitCompiledClasses($compiledClasses);
$this->emitCompiledClasses2($compiledClasses);
$this->emitCompiledClasses(array_keys($compiledClasses));
return count($compiledClasses);
}

Expand All @@ -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]);
}

/**
Expand Down
25 changes: 25 additions & 0 deletions Neos.Flow/Classes/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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
);
}
});
}
}