I want to implement php classes that should model the following : (Symfony,DoctrineMongoDBBundle)
Notification Collection { from { id , fname } , to , sentDate }
Member Collection { id , fname , lname , email , phone , regDate , ... }
And i want tell to ODM : "from field is an object that holds only 2 values ,id of the sender and his fname"
What annotation i must use? Should i define another class like from.php ? Or i can create two classes as the following:
/*
*@Document
*/
class Notification {
/*
*@Id
*/
protected $id;
/*
*@EmbedOne(targetDocument="Member")
*/
protected $from;
/*
*@ReferenceOne(targetDocument="Member")
*/
protected $to;
/*
*@Date
*/
protected $sentDate;
}
/*
*@Document
*/
class Member {
/*
*@Id
*/
protected $id;
/*
*@String
*/
protected $fname;
/*
*@String
*/
protected $lname;
/*
*@String
*/
protected $email;
.
.
.
}
If it's correct,in my controller how can i control "from" field to hold only id and fname from a Member object? suppose this:
$senderUser;
$newNotification = new Notification();
$newNotification->setFrom($senderUser);
Then $newNotification->from set to a Member object that hold all info about a Member.But i want only id and fname of the sender to persist! (because needs of my project) Excuse my English grammatical errors. Thanks for any help...