Comments (3)
Bonjour David,
On 12/06/12 17:09, david quintard wrote:
$view = new JsonModel(array(
‘adresse’ => $entitySerializer->toJson($candidat->getAdresse())
));
return $view;Ca marche pas non plus, soit j’ai des NULL pour les clés étrangeres soit j’ai meme pas les champs.
De plus j’ai un attribut isInitialized bizarre.{« adresse »: »{\ »isInitialized\ »:true} »}
Pour info $candidat->getAdresse() est un proxy sur ma classe Entity\Adresse.
Effectivement, je te conseille d'essayer en faisant un truc du genre
$adresse = $candidat->getAdresse();
Puis éventuellement de forcer le chargement de ton entité :
$adresse->__load();
En debuggant j'ai ici:
https://github.com/borisguery/bgylibrary/blob/master/library/Bgy/Doctrine/EntitySerializer.php#L80$data[$key] retourne null
\Zend\debug::dump($metadata->reflFields[$field]);
Pour info je te conseille d'utiliser
Doctrine\Common\Util\Debug::dump($entity); pour débugguer tes entités
Tu peux aussi utiliser l'annotation cascade={"detach"} dans la
déclaration de ta relation pour t'assurer que la relation soit
sérialisée en même temps que l'entité "parente". Attention tout de même
dans le cas des many to many car cela risque de charger l'ensemble de ta
collection...
Sinon comme tu as pu le constater il s'agit d'un système assez simple
qui convient bien a des petits besoins mais si tu as besoin d'un système
plus complexe qui nécessite plus d'options dans la sérialisation, je te
conseille de jeter un œil à
http://jmsyst.com/bundles/JMSSerializerBundle qui peut te donner une
piste plus complète sur la sérialisation d'entités.
Boris Guéry - Web Developer
Mobile: +33 6 86 83 03 12
E-mail: [email protected]
Skype: borisguery
from bgylibrary.
Je peux utiliser JMSSerializerBundle en tant que module de zf2, indépendamment de Symfony ?
"require-dev": {
"symfony/framework-bundle": "2.",
"symfony/yaml": "2.",
"symfony/form": "2.",
"symfony/validator": "2.",
"twig/twig": "dev-master"
},
from bgylibrary.
Pas aussi simplement : ) à ma connaissance le Serializer n'existe qu'en
Bundle et pas indépendamment, cependant tu peux regarder comment
celui-ci fonctionne ou encore le serializer natif de Symfony2 pour
écrire le tiens.
Après encore une fois tout dépend de ton cas d'utilisation. Ils sont
beaucoup plus riche en fonctionnalité mais pas forcément utile dans
certains cas.
On 12/06/12 19:36, david quintard wrote:
Je peux utiliser JMSSerializerBundle en tant que module de zf2, indépendamment de Symfony ?
Reply to this email directly or view it on GitHub:
#2 (comment)
Boris Guéry - Web Developer
Mobile: +33 6 86 83 03 12
E-mail: [email protected]
Skype: borisguery
from bgylibrary.
Related Issues (2)
- ZF2 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bgylibrary.