I am working with an embbeded document currently, and I need to get the account information from the parent document to generate an URL. How can I access the parent document from a getter on the embedded document?
/** @Document */
class User
{
// ...
/** @EmbedOne(targetDocument="Image") */
private $image;
/** @ReferenceOne(targetDocument="Account") */
private $account;
// ...
}
/** @EmbeddedDocument */
class Image
{
private $url;
public function getUrl(){
// sudo code. How do I do this?
return $this->getParent()->getAccount()->getDomain().$this->url;
}
}
Thanks, Cory
i'm afraid you can't if its embedded when you access Image you do it from User Document
so you have also access to account like this
You should write a twig helper or a custom function to build your url from User Document
I hope this help a little