Skip to content

Add XmlTemplateFormMetadataLoader to replace old structure based metadata loading #7982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

alexander-schranz
Copy link
Member

@alexander-schranz alexander-schranz commented Jun 2, 2025

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Fixed tickets fixes #
Related issues/PRs #7908
License MIT
Documentation PR sulu/sulu-docs#

What's in this PR?

Add new XmlTemplateFormMetadataLoader.

Why?

To replace old structure based metadata loading.

ToDo

  • Settings Form Key handling
  • Template Meta Title
  • Block MinOccurs
  • Tests

@@ -275,7 +275,7 @@ public function prependExtension(ContainerConfigurator $container, ContainerBuil
],
],
'templates' => [
'articles' => [
ArticleInterface::TEMPLATE_TYPE => [
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally would remove the "template_type" currently singleton (page, snippet, article) and replace it with the resource key (pages, snippets, articles) but that should be discussed and tackled in an own Pull request.

@alexander-schranz alexander-schranz force-pushed the feature/template-xml-loader branch from 4fac69f to f37b7ad Compare June 2, 2025 19:37
Comment on lines +81 to +93
$container->prependExtensionConfig(
'sulu_admin',
[
'templates' => [
'block' => [ // TODO maybe blocks?
'default_type' => null,
'directories' => [
'app' => '%kernel.project_dir%/config/templates/blocks',
],
],
],
]
);
Copy link
Member Author

@alexander-schranz alexander-schranz Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should move this in to the admin or content bundle not sure. Little bit splitted what the correct place is. /cc @Prokyonn, @chirimoya.

JS for global blocks is in the Admin Bundle. Metadata currently also. Template types definitions are in the specific bundles (articles, snippets, page).

Global Metadata service is currently in component would also required to move to the bundle which does the configuration.

Block json metadata which also handles global blocks is currently part of the block content type currently inside components. The block property resolver will be part of content bundle, the json metadata maybe also but would not be required, currently property resolver interface and json schema interfaces are on the same class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My gut feeling says contentBundle, but I cannot tell you a specific reason for it 😅, both cases are valid

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay lets tackle this in own PR my first indention was also content, thomas also, but discussion is will it be used outside of content bundle then it would be better to stay part of admin.

@@ -390,7 +390,7 @@ private function getTypes(): array
$metadata = $this->formMetadataProvider->getMetadata('page', $user->getLocale(), []);

foreach ($metadata->getForms() as $form) {
$types[] = ['type' => $form->getName(), 'title' => $form->getTitle($user->getLocale())];
$types[] = ['type' => $form->getKey(), 'title' => $form->getTitle($user->getLocale())];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm kind of confused about name and key in forms vs templates @Prokyonn lets discuss this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tackled in #7984

@alexander-schranz alexander-schranz force-pushed the feature/template-xml-loader branch from f37b7ad to e50f7b2 Compare June 2, 2025 20:13
@alexander-schranz alexander-schranz added the Feature New functionality not yet included in Sulu label Jun 2, 2025
@alexander-schranz alexander-schranz force-pushed the feature/template-xml-loader branch from e50f7b2 to e2eaaff Compare June 3, 2025 06:27
Comment on lines +231 to +233
<!--
<tag name="sulu_admin.form_metadata_loader"/>
-->
Copy link
Member Author

@alexander-schranz alexander-schranz Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently commented out but whole service should later be removed in upcoming PR with removing the structure metadata.

This PR responsibility is just replace all usage of metadata of the admin is not longer build on top of structure metadata instead using the new parsers of the admin bundle.

@alexander-schranz alexander-schranz force-pushed the feature/template-xml-loader branch 3 times, most recently from 5b97a69 to e2d388b Compare June 3, 2025 11:21
@alexander-schranz alexander-schranz force-pushed the feature/template-xml-loader branch from e2d388b to 4c9bdf8 Compare June 3, 2025 11:23
@@ -270,7 +270,7 @@
"required": false,
"multilingual": true,
"spaceAfter": null,
"minOccurs": null,
"minOccurs": 0,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO need to find out where this regression comes from.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually 0 is the correct value here:

<block name="blocks" default-type="text_block2" minOccurs="0">

Shold we convert 0 to null or keep it as it is now? /cc @Prokyonn

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think keeping it like this is more transparent

@alexander-schranz alexander-schranz force-pushed the feature/template-xml-loader branch from ee7b323 to 29c1e56 Compare June 3, 2025 14:24
/**
* @internal
*/
class BlockSettingsFormMetadataVisitor implements TypedFormMetadataVisitorInterface
Copy link
Member Author

@alexander-schranz alexander-schranz Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copied from StructureFormMetadataLoader which will get removed in upcoming PR

Comment on lines +49 to +55
'templates' => [
PageInterface::TEMPLATE_TYPE => [
'directories' => [
'app' => '%kernel.project_dir%/config/templates/pages',
],
],
],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

required currently also in the old page bundle as the new one is not registered yet in old other bundles because conflicts with the old one

@alexander-schranz alexander-schranz force-pushed the feature/template-xml-loader branch from e3aa8df to a0206cd Compare June 4, 2025 07:06
@alexander-schranz alexander-schranz added Technical Debt Impacts code quality, no or just small impact on end developers and users and removed Feature New functionality not yet included in Sulu labels Jun 4, 2025
@alexander-schranz alexander-schranz force-pushed the feature/template-xml-loader branch 3 times, most recently from 1c62983 to 73ca91d Compare June 4, 2025 07:55
@alexander-schranz alexander-schranz force-pushed the feature/template-xml-loader branch from 73ca91d to 1805f85 Compare June 4, 2025 08:16
@@ -270,7 +270,7 @@
"required": false,
"multilingual": true,
"spaceAfter": null,
"minOccurs": null,
"minOccurs": 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think keeping it like this is more transparent

Comment on lines +81 to +93
$container->prependExtensionConfig(
'sulu_admin',
[
'templates' => [
'block' => [ // TODO maybe blocks?
'default_type' => null,
'directories' => [
'app' => '%kernel.project_dir%/config/templates/blocks',
],
],
],
]
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My gut feeling says contentBundle, but I cannot tell you a specific reason for it 😅, both cases are valid

@alexander-schranz alexander-schranz force-pushed the feature/template-xml-loader branch from 8d29c51 to 10bc922 Compare June 4, 2025 11:44
@alexander-schranz alexander-schranz marked this pull request as ready for review June 4, 2025 16:19
@alexander-schranz alexander-schranz merged commit 75b2678 into sulu:3.0 Jun 5, 2025
9 checks passed
@alexander-schranz alexander-schranz deleted the feature/template-xml-loader branch June 5, 2025 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Technical Debt Impacts code quality, no or just small impact on end developers and users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants