This is really old so you've probably found the solution to your error. But
in case anyone else searches for this and finds this thread the fix is
simple:
decrease the indentation on the embedOne, it should be at the same
indentation as 'fields', not 'username' as the example above.
A simple one that had me stumped for a little bit.
Cheers,
Doug
On Friday, July 6, 2012 9:54:47 AM UTC+10, pc wrote:
>
> The error that I'm getting is this:
>
> request.CRITICAL: ErrorException: Notice: Undefined index: type in
> /var/www/html/Symfony/vendor/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php
>
> line 190 (uncaught exception) at
> /var/www/html/Symfony/vendor/symfony/src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php
>
> line 67 [] []
>
> Related info from my deps.lock:
> symfony v2.0.13
> doctrine-common 2.2.1
> doctrine-dbal 2.2.1
> doctrine 2.2.1
> doctrine-mongodb b5c5d0499f4db2531de6eea54d38b75e485ceef4
> doctrine-mongodb-odm e2c1fbf7258e29d7a3dd59c4491a3baa2aea1c8f
> DoctrineMongoDBBundle 50479f70f3ac02461ed2edbc52c141d16b7d25c0
>
> On Thursday, July 5, 2012 3:56:03 PM UTC-7, pc wrote:
>>
>> Hi All,
>> I'm trying to define my mapping using YAML. I'm able to do
>> references. But I get errors using embedded documents. Below is my code.
>> Can someone please help and point out what I'm doing wrong? Appreciate your
>> help.
>>
>> --------------Start MyApp.Models.LastKnownData.dcm.yml ----------------
>> MyApp\Models\LastKnownData:
>> fields:
>> id:
>> type: id
>> id: true
>> strategy: AUTO
>> username:
>> type: string
>> embedOne:
>> userdata:
>> targetDocument: MyApp\Models\Userdata
>>
>> ------------end--------------
>>
>> --------------Start MyApp.Models.Userata.dcm.yml----------------
>> MyApp\Models\Userdata:
>> type: embeddedDocument
>> fields:
>> lat:
>> type: float
>> lon:
>> type: float
>> --------------end------------------
>>
>>
>> -------Start LastKnownData.php----------
>> <?php
>>
>> namespace MyApp\Models;
>>
>>
>> class LastKnownData
>> {
>> private $id;
>> private $username;
>> private $userdata;
>>
>> function __construct($username, $userdata=null)
>> {
>> $this->username = $username;
>> $this->userdata = $userdata;
>> }
>>
>> public function getUsername()
>> {
>> return $this->username;
>> }
>>
>> public function getUserdata()
>> {
>> return $this->userdata;
>> }
>> }
>> -------end---------------------
>>
>> -------Start Userdata.php----------
>> ?>
>> <?php
>>
>> namespace MyApp\Models;
>>
>> class Userdata
>> {
>> private $id;
>> private $lat;
>> private $lon;
>>
>> function __construct($lat, $lon)
>> {
>> $this->lat = $lat;
>> $this->lat = $lon;
>> }
>>
>> public function getLat()
>> {
>> return $this->lat;
>> }
>>
>> public function getLon()
>> {
>> return $this->lon;
>> }
>>
>> public function setLatLon($lat, $lon)
>> {
>> $this->lat = $lat;
>> $this->lon = $lon;
>> }
>> }
>>
>> ?>
>> -------end---------------------
>>
>
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.