-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathFakeNodeTypeManagerTrait.php
More file actions
45 lines (36 loc) · 1.29 KB
/
FakeNodeTypeManagerTrait.php
File metadata and controls
45 lines (36 loc) · 1.29 KB
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
<?php
declare(strict_types=1);
namespace Flowpack\NodeTemplates\Tests\Functional;
use Neos\ContentRepository\Domain\Service\NodeTypeManager;
use Neos\Flow\Configuration\ConfigurationManager;
use Neos\Utility\Arrays;
use Symfony\Component\Yaml\Yaml;
/**
* @property NodeTypeManager $nodeTypeManager
*/
trait FakeNodeTypeManagerTrait
{
/**
* @template T of object
* @param class-string<T> $className
*
* @return T
*/
abstract protected function getObject(string $className): object;
private function loadFakeNodeTypes(): void
{
$configuration = $this->getObject(ConfigurationManager::class)->getConfiguration('NodeTypes');
$fileIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__ . '/Features'));
/** @var \SplFileInfo $fileInfo */
foreach ($fileIterator as $fileInfo) {
if (!$fileInfo->isFile() || $fileInfo->getExtension() !== 'yaml' || strpos($fileInfo->getBasename(), 'NodeTypes.') !== 0) {
continue;
}
$configuration = Arrays::arrayMergeRecursiveOverrule(
$configuration,
Yaml::parseFile($fileInfo->getRealPath()) ?? []
);
}
$this->nodeTypeManager->overrideNodeTypes($configuration);
}
}