flowpack / nodegenerator
Neos CMS 的随机节点生成器
1.1.0
2020-08-03 13:36 UTC
Requires
- fzaninotto/faker: ~1.8
- neos/neos: ~3.3 || ~4.0 || ~5.0
This package is auto-updated.
Last update: 2024-09-05 16:34:39 UTC
README
节点生成器类的配置
在您的 Settings.yaml 中,您可以注册一个节点生成器类。您的设置中使用的每个节点类型都必须有一个附加的生成器类。
Flowpack: NodeGenerator: generator: 'Neos.NodeTypes:Page': class: 'Flowpack\NodeGenerator\Generator\Document\PageGeneratorImplementation' 'Neos.NodeTypes:Text': class: 'Flowpack\NodeGenerator\Generator\Content\TextGeneratorImplementation' 'Neos.NodeTypes:Image': class: 'Flowpack\NodeGenerator\Generator\Content\ImageGeneratorImplementation' 'Neos.NodeTypes:TextWithImage': class: 'Flowpack\NodeGenerator\Generator\Content\TextWithImageGeneratorImplementation'
最小生成器类
调用您的节点生成器类的节点生成器会捕获 NodeExistsException,因此您不需要担心。生成器将静默地跳过内容库中当前存在的节点。
class PageGeneratorImplementation extends AbstractNodeGeneratorImplementation { /** * @param NodeInterface $parentNode * @param NodeType $nodeType * @return NodeInterface */ public function create(NodeInterface $parentNode, NodeType $nodeType) { $title = Company::name(); $name = Utility::renderValidNodeName($title); $childrenNode = $parentNode->createNode($name, $nodeType); $childrenNode->setProperty('title', $title); return $childrenNode; } }
预设配置
如果配置了多个内容节点和文档节点类型,生成器将为每个新节点选择一个随机节点类型。请确保为每个节点类型声明一个生成器类。
该扩展附带了一些预设的示例,一个基本的预设看起来像
Flowpack: NodeGenerator: preset: # Basic website, with a multiple level page tree small-website: depth: 3 nodeByLevel: 10 contentNodeByDocument: 5 documentNodeType: [ 'Neos.NodeTypes:Page' ] contentNodeType: [ 'Neos.NodeTypes:Text', 'Neos.NodeTypes:Images' ] # Randomness of the number of nodes generated from 0 to 100 randomness: 25
运行您的预设
./flow generator:nodes --site-node blog --preset small-blog
配置根节点
默认情况下,所有生成的页面都将创建在网站的根级别。此行为可以通过提供现有节点的特定路径来更改。
flow generator:nodes --site-node homepage --preset small-blog --path blog