Last active
August 29, 2015 14:07
-
-
Save digitalkaoz/90644937a322b3739bd2 to your computer and use it in GitHub Desktop.
serializer for external classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/config/config.yml | |
jms_serializer: | |
metadata: | |
directories: | |
my-file: | |
namespace_prefix: "My\\Ns" | |
path: "@MyNsBundle/Resources/config/serializer" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// My/Ns/File | |
namespace My\Ns; | |
class File | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- My/Ns/Bundle/Resources/config/serializer/My.Ns.File.xml --> | |
<?xml version="1.0" encoding="UTF-8" ?> | |
<serializer> | |
<class name="My\Ns\File" exclusion-policy="ALL"> | |
</class> | |
</serializer> | |
The file name with dot-separated components of the class name should not include the namespace prefix. this is exactly what the namespace prefix is about: shortening the file name by allowing to omit the namespace prefix when all classes mapping in your folder are sharing the same namespace prefix.
then the documentation is misleading somehow? http://jmsyst.com/libs/serializer/master/reference/xml_reference ?
mh still not working:
jms_serializer:
metadata:
directories:
issues:
namespace_prefix: "Rs\\Issues\\"
path: "@RsIssuesBundle/Resources/config/serializer"
ls -la vendor/digitalkaoz/issues-bundle/Resources/config/serializer/
Github.GithubIssue.xml
Github.GithubProject.xml
<?xml version="1.0" encoding="UTF-8" ?>
<serializer>
<class name="Rs\Issues\Github\GithubProject" exclusion-policy="ALL">
<!-- ... -->
</class>
@stof this should be correct or?
Try removing the \
at the end of the namespace prefix to see whether it fixes it (I don't use a trailing backslash in my working config, I don't know whether it is important)
tried it in all variations :/
got it working:
jms_serializer:
metadata:
directories:
issues:
namespace_prefix: "Rs\\Issues"
path: "@RsIssuesBundle/Resources/config/serializer/issues"
ls -la vendor/digitalkaoz/issues-bundle/Resources/config/serializer/issues
Github.GithubIssue.xml
Github.GithubProject.xml
<?xml version="1.0" encoding="UTF-8" ?>
<serializer>
<class name="Rs\Issues\Github\GithubProject" exclusion-policy="ALL">
<!-- ... -->
</class>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
why is the mapping not work?