/
Package.php
75 lines (68 loc) · 2.99 KB
/
Package.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
namespace Neos\Fusion;
/*
* This file is part of the Neos.Fusion 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\Cache\CacheManager;
use Neos\Flow\Core\Booting\Sequence;
use Neos\Flow\Core\Bootstrap;
use Neos\Flow\Monitor\FileMonitor;
use Neos\Flow\Package\Package as BasePackage;
use Neos\Flow\Package\PackageManager;
use Neos\Fusion\Core\Cache\FileMonitorListener;
use Neos\Fusion\Core\Cache\ParserCacheFlusher;
/**
* The Neos Fusion Package
*/
class Package extends BasePackage
{
/**
* 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(Sequence::class, 'afterInvokeStep', function ($step) use ($bootstrap, $dispatcher) {
if ($step->getIdentifier() === 'neos.flow:systemfilemonitor') {
$fusionFileMonitor = FileMonitor::createFileMonitorAtBoot('Fusion_Files', $bootstrap);
/** @var PackageManager $packageManager */
$packageManager = $bootstrap->getEarlyInstance(PackageManager::class);
foreach ($packageManager->getFlowPackages() as $packageKey => $package) {
if ($packageManager->isPackageFrozen($packageKey)) {
continue;
}
$fusionPaths = [
$package->getResourcesPath() . 'Private/Fusion',
$package->getPackagePath() . 'NodeTypes'
];
foreach ($fusionPaths as $fusionPath) {
if (is_dir($fusionPath)) {
$fusionFileMonitor->monitorDirectory($fusionPath);
}
}
}
$fusionFileMonitor->detectChanges();
$fusionFileMonitor->shutdownObject();
}
if ($step->getIdentifier() === 'neos.flow:cachemanagement') {
$cacheManager = $bootstrap->getEarlyInstance(CacheManager::class);
$listener = new FileMonitorListener($cacheManager);
$dispatcher->connect(FileMonitor::class, 'filesHaveChanged', $listener, 'flushContentCacheOnFileChanges');
$parsePartialCacheFlusher = new ParserCacheFlusher($cacheManager);
$dispatcher->connect(FileMonitor::class, 'filesHaveChanged', $parsePartialCacheFlusher, 'flushPartialCacheOnFileChanges');
}
});
}
}
}