2

I'm trying to persist some data to MongoDB with Docrtrine (symfony2.1). Here are my entities:

// src/Acme/ReportsBundle/Entity/ReportCore.php
namespace Acme\ReportsBundle\Entity;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use Doctrine\Common\Collections\ArrayCollection;
/**
 * @MongoDB\Document(collection="registeredReports")
 */
class ReportCore {

/**
* @MongoDB\Id
*/
protected $id;

/**
* @MongoDB\String
*/
protected $title;

/**
* @MongoDB\String
*/
protected $description;

/**
* @MongoDB\String
*/
protected $reference;

/**
* @MongoDB\Date
*/
protected $created;

/**
* @MongoDB\Date
*/
protected $createdBy;

/**
* @MongoDB\EmbedMany(targetDocument="ReportFields")
*/
protected $fields = array();

public function __construct () {
    $this->fields = new ArrayCollection();
}
// Setters, getters
}

Here's embedded document:

// src/Acme/ReportsBundle/Entity/ReportFields.php
namespace Acme\ReportsBundle\Entity;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
 *  @MongoDB\EmbeddedDocument
 */
class ReportFields {
/**
 * @MongoDB\Id
 */
protected $id;

/**
 * @MongoDB\String
 */
protected $title;

/**
 * @MongoDB\String
 */
protected $description;

/**
 * @MongoDB\String
 */
protected $name;

/**
 * @MongoDB\String
 */
protected $type;

    //Setters-getters...
}

and here is controller:

// src/Acme/ReportsBundle/Controller/ReportsController.php
namespace Acme\ReportsBundle\Controller;
use Acme\ReportsBundle\Entity\ReportCore;
use Acme\ReportsBundle\Entity\ReportFields;
use Acme\ReportsBundle\Form\Type\ReportCoreType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class ReportsController extends Controller {
    public function newAction (Request $request) {
$report = new ReportCore();
$fields1 = new ReportFields();
$report->getFields()->add($fields1);
$form = $this->createForm(new ReportCoreType(), $report);
    if ( $request->isMethod('POST') ) {
    $form->bind($request);
    if ( $form->isValid() ) {
        $dm = $this->get('doctrine_mongodb')->getManager();
    $dm->persist($report);
    $dm->flush();
    }
}
return $this->render('AcmeReportsBundle:Report:new.html.twig', array(
            'form' => $form->createView()
        ));
}

My problem is - when I try to persist data to database, I get

The class 'Acme\ReportsBundle\Entity\ReportCore' was not found in the chain configured namespaces FOS\UserBundle\Document

As I'm quite new to Symfony and Doctrine - I can't figure out what it has to do with FOSUserBundle, and what am I doing wrong.

2
  • Have you updated your database schema? php app/console doctrine:schema:update --force; Commented Jan 29, 2013 at 7:10
  • I don't think that this is the case, working with MongoDB, but I tried it just now - it says "Nothing to update - your database is already in sync with the current entity metadata." The error, however is still there... Commented Jan 29, 2013 at 7:15

1 Answer 1

2

Your MongoDb-Schemas should be within the Document namespace

namespace Acme\ReportsBundle\Document;

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.