Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Invalid
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Persister
-
Labels:None
Description
LifecycleCallbacks in EmbeddedDocument are not called
/**
* @EmbeddedDocument
* @HasLifecycleCallbacks
*/
class SocialNetworkUser {
/**
* @Int(name="id")
* @var int
*/
protected $id;
/**
* @String(name="fN")
* @var string
*/
protected $firstName;
/**
* @String(name="lN")
* @var string
*/
protected $lastName;
/**
* @NotSaved
* @var string
*/
protected $name;
// ....
/**
* @PostLoad
*/
public function postLoad() {
$this->name = $this->firstName . ' ' . $this->lastName;
}
}
/**
* @Document(collection="users")
*/
class User {
/**
* @Id
*/
protected $id;
/**
* @EmbedOne(
* discriminatorField="php",
* discriminatorMap={
* "fbu"="Documents\SocialNetworkUser "
* },
* name="snu",
* cascade={"persist", "remove"}
* )
*/
protected $socialNetworkUser;
}
$_user = $this->dm->findOne('Documents\User', array('snu.id' => $uid));
print_r($_user->getSocialNetworkUser()->getName())
$name is empty.
postLoad is never called after load
Sorry, my mistake.
.
I have forgotten "callbacks" in cascade attribute