Skip to content
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

Problems with JMS-Metadata-Generator #137

Closed
time85 opened this issue Jun 29, 2021 · 4 comments
Closed

Problems with JMS-Metadata-Generator #137

time85 opened this issue Jun 29, 2021 · 4 comments

Comments

@time85
Copy link

time85 commented Jun 29, 2021

Hello, have to implement an OTA-Fork called Alpinebits.
Link to the documentation: Alpinebits-Documentation

I use xsd2php and the JMS-Serializer which is an awesome combination!!!

But the xsd-schema is very nested and during generation, i get errors for some nested elements, that the filename is longer than 255.

Are there possibilities to solve this Problem ?

Warning: file_put_contents(include/Import/Ota/Implementations/Alpinebits201710/metadata/OTAHotelDescriptiveContentNotifRQ.OTAHotelDescriptiveContentNotifRQAType.HotelDescriptiveContentsAType.HotelDescriptiveContentAType.FacilityInfoAType.GuestRoomsAType.GuestRoomAType.MultimediaDescriptionsAType.MultimediaDescriptionAType.ImageItemsAType.ImageItemAType.yml): failed to open stream: File name too long in .....vendor/goetas-webservices/xsd2php/src/Writer/JMSWriter.php on line 32

My config.yml

# config.yml

xsd2php:
  namespaces:
    'http://www.opentravel.org/OTA/2003/05': 'Import\Ota\Alpinebits202010'
  destinations_php:
    'Import\Ota\Alpinebits202010': include/Import/Ota/Implementations/Alpinebits202010/src

  destinations_jms:
    'Import\Ota\Alpinebits202010': include/Import/Ota/Implementations/Alpinebits202010/metadata

 
  aliases: # optional
  naming_strategy: short # optional and default
  path_generator: psr4 # optional and default

Some generated Metadata-Definitions

OTAHotelDescriptiveContentNotifRQ.OTAHotelDescriptiveContentNotifRQAType.HotelDescriptiveContentsAType.HotelDescriptiveContentAType.AffiliationInfoAType.yml
OTAHotelDescriptiveContentNotifRQ.OTAHotelDescriptiveContentNotifRQAType.HotelDescriptiveContentsAType.HotelDescriptiveContentAType.ContactInfosAType.yml
OTAHotelDescriptiveContentNotifRQ.OTAHotelDescriptiveContentNotifRQAType.HotelDescriptiveContentsAType.HotelDescriptiveContentAType.FacilityInfoAType.GuestRoomsAType.GuestRoomAType.AmenitiesAType.AmenityAType.yml
OTAHotelDescriptiveContentNotifRQ.OTAHotelDescriptiveContentNotifRQAType.HotelDescriptiveContentsAType.HotelDescriptiveContentAType.FacilityInfoAType.GuestRoomsAType.GuestRoomAType.AmenitiesAType.yml
OTAHotelDescriptiveContentNotifRQ.OTAHotelDescriptiveContentNotifRQAType.HotelDescriptiveContentsAType.HotelDescriptiveContentAType.FacilityInfoAType.GuestRoomsAType.GuestRoomAType.MultimediaDescriptionsAType.MultimediaDescriptionAType.ImageItemsAType.yml
OTAHotelDescriptiveContentNotifRQ.OTAHotelDescriptiveContentNotifRQAType.HotelDescriptiveContentsAType.HotelDescriptiveContentAType.FacilityInfoAType.GuestRoomsAType.GuestRoomAType.MultimediaDescriptionsAType.MultimediaDescriptionAType.TextItemsAType.yml
OTAHotelDescriptiveContentNotifRQ.OTAHotelDescriptiveContentNotifRQAType.HotelDescriptiveContentsAType.HotelDescriptiveContentAType.FacilityInfoAType.GuestRoomsAType.GuestRoomAType.MultimediaDescriptionsAType.MultimediaDescriptionAType.yml
OTAHotelDescriptiveContentNotifRQ.OTAHotelDescriptiveContentNotifRQAType.HotelDescriptiveContentsAType.HotelDescriptiveContentAType.FacilityInfoAType.GuestRoomsAType.GuestRoomAType.MultimediaDescriptionsAType.yml
OTAHotelDescriptiveContentNotifRQ.OTAHotelDescriptiveContentNotifRQAType.HotelDescriptiveContentsAType.HotelDescriptiveContentAType.FacilityInfoAType.GuestRoomsAType.GuestRoomAType.TypeRoomAType.yml
OTAHotelDescriptiveContentNotifRQ.OTAHotelDescriptiveContentNotifRQAType.HotelDescriptiveContentsAType.HotelDescriptiveContentAType.FacilityInfoAType.GuestRoomsAType.GuestRoomAType.yml
OTAHotelDescriptiveContentNotifRQ.OTAHotelDescriptiveContentNotifRQAType.HotelDescriptiveContentsAType.HotelDescriptiveContentAType.FacilityInfoAType.GuestRoomsAType.yml
@goetas
Copy link
Member

goetas commented Jun 29, 2021

hmm, that is nice
what you can do is to implement a custom naming strategy and find a way to shorten the name

@time85
Copy link
Author

time85 commented Jun 30, 2021

thanks for the help :)

I've managed to create a naming strategy, mentioned in this PR:
#49 (comment)

@goetas goetas closed this as completed Jun 30, 2021
@time85
Copy link
Author

time85 commented Jul 1, 2021

to clarify, i had to take another path. the CustomNamingStrategy made problems when trying to (de)serialize, i wasn't able to create the php-object or a schema-valid xml file.

i had to change the generation part:
Created my own JMSWriter to create (sub)folders like in the generation of the php-files and add him to the config.yml

i had to change the (de)serializaion part -> jms-serializer:
created my own FileLocator and set him through:

 $serializerBuilder->setMetadataDriverFactory(new CallbackDriverFactory(function ($metadataDirs, Reader $reader) {
            return new DriverChain([
                new YamlDriver(new MyOwnFileLocator($metadataDirs), new SerializedNameAnnotationStrategy(new CamelCaseNamingStrategy())),
                new AnnotationDriver($reader, new SerializedNameAnnotationStrategy(new CamelCaseNamingStrategy())),
            ]);
        }));

atm it looks like all tests are green :)

@goetas
Copy link
Member

goetas commented Jul 1, 2021

nice idea...

having such MyOwnFileLocator in the jms/serializer would be nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants