Reusable bundle with predefined document types #17022
Unanswered
twin-elements
asked this question in
Q&A / Support
Replies: 1 comment
-
You would need to install the predefined document types via a installer. e.g. something like this: $docTypeConfigs = [
[
'name' => 'Test Page',
'controller' => TestController::class . '::testAction',
'type' => 'page',
],
];
foreach ($docTypeConfigs as $docTypeConfig) {
$exists = false;
$docTypes = new Listing();
/**
* @var DocType $docType
*/
foreach ($docTypes->load() as $docType) {
if ($docType->getController() === $docTypeConfig['controller']) {
$exists = true;
break;
}
}
if (!$exists) {
(new DocType())
->setName($docTypeConfig['name'])
->setGroup('My Custom Bundle')
->setController($docTypeConfig['controller'])
->setType($docTypeConfig['type'])
->save();
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi.
I need to create a reusable bundle that contains predefined document types.
I have not found anything about this in the documentation.
Can anyone give an example?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions