Skip to content

Commit

Permalink
TASK: Create a custom document node type for the site root node
Browse files Browse the repository at this point in the history
Relates: neos/neos-development-collection#4563
Relates: neos/neos-development-collection#4567
  • Loading branch information
ahaeslich committed Jun 10, 2024
1 parent c4f97ae commit bcdbbb8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
28 changes: 10 additions & 18 deletions Classes/Generator/AfxTemplateGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* source code.
*/

use Neos\ContentRepository\Core\SharedModel\Node\NodeName;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Package\PackageManager;
use Neos\Kickstarter\Service\GeneratorService;
Expand Down Expand Up @@ -86,11 +85,8 @@ protected function generateSitesFusionDirectory(string $packageKey, string $site
$contextVariables['siteNodeName'] = $packageKeyDomainPart;

$fusionRecursiveDirectoryRenderer = new FusionRecursiveDirectoryRenderer();

$packageDirectory = $this->packageManager->getPackage('Neos.SiteKickstarter')->getResourcesPath();

$fusionRecursiveDirectoryRenderer->renderDirectory(
$packageDirectory . 'Private/AfxGenerator/Fusion',
$this->getTemplateFolder() . 'Fusion',
$this->packageManager->getPackage($packageKey)->getResourcesPath() . 'Private/Fusion',
$contextVariables
);
Expand All @@ -104,16 +100,18 @@ protected function generateSitesFusionDirectory(string $packageKey, string $site
*/
protected function generateNodeTypesConfiguration(string $packageKey) : void
{
$templatePathAndFilename = $this->getResourcePathForFile('Configuration/NodeTypes.Document.Page.yaml');
$templateFolder = $this->getTemplateFolder() . 'NodeTypes';
$targetFolder = $this->packageManager->getPackage($packageKey)->getPackagePath() . 'NodeTypes';

$contextVariables = [
'packageKey' => $packageKey
];

$fileContent = $this->simpleTemplateRenderer->render($templatePathAndFilename, $contextVariables);

$sitesNodeTypesPathAndFilename = $this->packageManager->getPackage($packageKey)->getConfigurationPath() . 'NodeTypes.Document.Page.yaml';
$this->generateFile($sitesNodeTypesPathAndFilename, $fileContent);
foreach (Files::readDirectoryRecursively($templateFolder, '.yaml') as $templatePathAndFilename) {
$fileContent = $this->simpleTemplateRenderer->render($templatePathAndFilename, $contextVariables);
$targetPathAndFilename = str_replace($templateFolder, $targetFolder, $templatePathAndFilename);
$this->generateFile($targetPathAndFilename, $fileContent);
}
}

/**
Expand All @@ -133,15 +131,9 @@ protected function generateAdditionalFolders(string $packageKey) : void
}
}

/**
* returns resource path for the generator
*
* @param $pathToFile
* @return string
*/
protected function getResourcePathForFile(string $pathToFile) : string
protected function getTemplateFolder(): string
{
return 'resource://Neos.SiteKickstarter/Private/AfxGenerator/' . $pathToFile;
return $this->packageManager->getPackage('Neos.SiteKickstarter')->getResourcesPath() . 'Private/AfxGenerator/';
}

public function getGeneratorName(): string
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
prototype({packageKey}:Document.Homepage) < prototype({packageKey}:Document.AbstractPage)
11 changes: 11 additions & 0 deletions Resources/Private/AfxGenerator/NodeTypes/Document.Homepage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This is a custom root node type which has been auto-generated for your site package
# by Neos. You can customize this to your needs.
'{packageKey}:Document.Homepage':
superTypes:
'Neos.Neos:Site': true
ui:
icon: globe
label: '{packageKey} Homepage'
childNodes:
main:
type: 'Neos.Neos:ContentCollection'

0 comments on commit bcdbbb8

Please sign in to comment.