diff --git a/Classes/Eel/Helper/PackageManagerHelper.php b/Classes/Eel/Helper/PackageManagerHelper.php new file mode 100644 index 0000000..7f8ffea --- /dev/null +++ b/Classes/Eel/Helper/PackageManagerHelper.php @@ -0,0 +1,58 @@ +getNeosUiVersion()); + } + + /** + * @return string + */ + public function getNeosUiMinorVersion(): string + { + return preg_replace('#^v?(\d+)\.(\d+)\.(\d+)$#', '$1.$2', $this->getNeosUiVersion()); + } + + /** + * @return string + */ + public function getNeosUiVersion(): string + { + try { + $packageManager = $this->objectManager->get(PackageManager::class); + $neosUiPackage = $packageManager->getPackage('Neos.Neos.Ui'); + return $neosUiPackage->getInstalledVersion(); + } catch (UnknownPackageException $e) { + return '0.0.0'; + } + } + + /** + * All methods are considered safe + * + * @param string $methodName + * @return boolean + */ + public function allowsCallOfMethod($methodName): bool + { + return true; + } +} diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index 7b930a9..d5ccdc7 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -1,4 +1,7 @@ Neos: + Fusion: + defaultContext: + 'Breadlesscode.NodeTypes.Folder.PackageManager': 'Breadlesscode\NodeTypes\Folder\Eel\Helper\PackageManagerHelper' Neos: userInterface: translation: diff --git a/Resources/Private/Fusion/Document/Folder.fusion b/Resources/Private/Fusion/Document/Folder.fusion index 74d41de..a31a163 100644 --- a/Resources/Private/Fusion/Document/Folder.fusion +++ b/Resources/Private/Fusion/Document/Folder.fusion @@ -26,16 +26,22 @@ prototype(Breadlesscode.NodeTypes.Folder:Document.Folder) < prototype(Neos.Fusio } body { templatePath = 'resource://Breadlesscode.NodeTypes.Folder/Private/Templates/Folder.html' - title = ${q(node).property('title')} + title = ${q(documentNode).property('title')} + version = ${Breadlesscode.NodeTypes.Folder.PackageManager.getNeosUiMajorVersion()} } } } default { condition = true - renderer = Neos.Neos:Page { - body = Neos.Neos:Shortcut { - targetMode = 'parentNode' + renderer = Neos.Fusion:Http.Message { + httpResponseHead { + statusCode = 301 + headers { + Location = Neos.Neos:NodeUri { + node = ${q(documentNode).parent().get(0)} + } + } } } } diff --git a/Resources/Private/Templates/Folder.html b/Resources/Private/Templates/Folder.html index 915e026..abee294 100644 --- a/Resources/Private/Templates/Folder.html +++ b/Resources/Private/Templates/Folder.html @@ -1,4 +1,4 @@ -