-
Notifications
You must be signed in to change notification settings - Fork 350
Support multiple form metadata loaders #4643
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
Support multiple form metadata loaders #4643
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markusmoosbrugger the PR Example Usage is missleading it should be a example with sulu_admin.metadata_loader
like: https://github.com/sulu/SuluFormBundle/pull/192/files#diff-1c64574ff1f633f0df3aac6fa7a25c7b
src/Sulu/Bundle/AdminBundle/Metadata/PropertiesMetadata/PropertiesXmlLoader.php
Outdated
Show resolved
Hide resolved
6d5ef17
to
f9f6251
Compare
src/Sulu/Bundle/AdminBundle/Metadata/PropertiesMetadata/PropertiesXmlLoader.php
Outdated
Show resolved
Hide resolved
src/Sulu/Bundle/AdminBundle/FormMetadata/FormMetadataMapper.php
Outdated
Show resolved
Hide resolved
src/Sulu/Bundle/AdminBundle/FormMetadata/FormMetadataMapper.php
Outdated
Show resolved
Hide resolved
src/Sulu/Bundle/AdminBundle/Metadata/FormMetadata/LocalizedFormMetadataCollection.php
Show resolved
Hide resolved
src/Sulu/Bundle/AdminBundle/Tests/Unit/FormMetadata/FormMetadataMapperTest.php
Outdated
Show resolved
Hide resolved
src/Sulu/Bundle/AdminBundle/Tests/Unit/FormMetadata/FormMetadataMapperTest.php
Outdated
Show resolved
Hide resolved
src/Sulu/Bundle/AdminBundle/Tests/Unit/FormMetadata/FormXmlLoaderTest.php
Outdated
Show resolved
Hide resolved
'first' => [ | ||
'name' => 'first', | ||
'const' => 1, | ||
'allOf' => [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure these changes are ok? Seems like it behaves differently as before...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The merging of schema information happened previously in the FormMetadataProvider and now it's already done in the FormXmlLoader and so the FormXmlLoader returns the merged schema information.
As the properties first and third are mandatory it seems correct to me that they are contained in the schema.
The XML file for the forms are loaded everytime in dev mode, instead of being taken from the cache. |
…and form xml loader tests are not adapted yet
(not finished yet)
StructureLoader and FormMetadataXmlLoader now responsible for caching; FormXmlLoader returns collection of FormMetadata; Marked old Metadata classes as deprecated
Also some php-cs fixes
Removed local variable which is not needed anymore
0dbe383
to
04a514d
Compare
What's in this PR?
This PR adds the support for multiple form metadata loaders. The different FormMetadataLoader classes can be tagged in the associated services.xml files as sulu_admin.form_metadata_loader in order to get injected automatically in the FormMetadataProvider. The different FormMetadataLoader classes must implement the Interface FormMetadataLoaderInterface.
Furthermore this PR changes the loading and caching mechanism of form metadata. The FormXmlLoader returns now an instance of LocalizedFormMetadataCollection, which contains a FormMetadata object for each locale. Instead of the old metadata objects, the newer ones are used now. The old metadata classes are now marked as deprecated.
The XmlFormMetadataLoader implements the FormMetadataLoaderInterface and provides the functionality to load and cache the form metadata. This was done previously in the FormMetadataProvider.
The StructureFormMetadataLoader is added as well in this PR and also implements the FormMetadataLoaderInterface. The StructureLoader is responsible for caching the structure metadata.
The class FormMetadataMapper handles the conversation between old and new metadata objects and is used in the XmlFormMetadataLoader, StructureFormMetadataLoader and FormXmlLoader.
Why?
Enable to use a custom metadata loader provided from the form bundle (see PR sulu/SuluFormBundle#192) . The functionality can also be useful for other bundles that want to provide their own metadata loader.
The modification to use the new metadata classes in the FormXmlLoader is necessary to avoid the usage of the old metadata objects in new loaders.
Example Usage
Add a service that implements the FormMetadataLoaderInterface. Afterwards tag this service in the services.xml file as sulu_admin.form_metadata_loader.
Example:
BC Breaks/Deprecations
Describe BC breaks/deprecations here. (remove this section if not needed)
To Do