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

Class ... does not exist in ...MetadataFactory.php #81

Closed
ander-chan opened this issue Jan 18, 2019 · 5 comments
Closed

Class ... does not exist in ...MetadataFactory.php #81

ander-chan opened this issue Jan 18, 2019 · 5 comments

Comments

@ander-chan
Copy link

Hi, I'm deserialize the implementation for UBL in my country, It's so wonderful tool generating code (Thanks!!) but my code not find the metadata classes. What i'm wrong !?

## YAML Template.
xsd2php:
  namespaces:
    'http://www.dian.gov.co/contratos/facturaelectronica/v1': DIAN\UBL
    'http://www.dian.gov.co/contratos/facturaelectronica/v1/Structures': DIAN\UBL\Structures
    'urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2': DIAN\UBL\IANAMIMEMediaType
  ....
  destinations_php: 
    DIAN\UBL: src/DIAN/UBL
    DIAN\UBL\Structures': src/DIAN/UBL/Structures
    DIAN\UBL\CommonExtensionComponents': src/DIAN/UBL/CommonExtensionComponents
    ....
  destinations_jms:
    DIAN\UBL: metadata_/DIAN/UBL
    DIAN\UBL\Structures': metadata_/DIAN/UBL/Structures
    DIAN\UBL\CommonExtensionComponents: metadata_/DIAN/UBL/CommonExtensionComponents
    ....

Metadta files:

.
+-- metadata_
|   +-- DIAN
|   |   +-- UBL
|   |   |   +-- Invoice.yml

Code:

...
$serializerBuilder->addMetadataDir(__DIR__.'/metadata_/DIAN/UBL','DIAN\\UBL\\');
$xml=file_get_contents("./eg/especific/invoice__paymentTerms__invoicePeriod_pagoA90dias_1dXf-s.xml");
$object = $serializer->deserialize($xml, "Invoice", 'xml');
...

dianubl2.tar.gz

Fatal error: Uncaught ReflectionException: Class Invoice does not exist in /.../src/MetadataFactory.php:170
Stack trace:
#0 /.../src/MetadataFactory.php(170): ReflectionClass->__construct('Invoice')

$php -v
PHP 7.2.14-1+ubuntu16.04.1+deb.sury.org+1...
@goetas
Copy link
Member

goetas commented Jan 19, 2019

I guess, Invoice should have the full class name including namespace

@goetas goetas closed this as completed Jan 19, 2019
@goetas
Copy link
Member

goetas commented Jan 21, 2019

what about Invoice ? which FQCN has?

@ander-chan
Copy link
Author

I was check it DIAN/UBL/Invoice, sorry, the the metadatafactory is empty, I debug the FileLocator from this post schmittjoh/JMSSerializerBundle#650 (comment)
The findFileForClass and findAllClasses has never has been excuted.

@goetas
Copy link
Member

goetas commented Jan 21, 2019

your php code should be ù

$object = $serializer->deserialize($xml, 'DIAN\UBL\Invoice', 'xml');

@ander-chan
Copy link
Author

yeah! $object = $serializer->deserialize($xml, "DIAN\UBL\Invoice", 'xml');

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