I downloaded the MongoODM Doctrine module for zf2. I have a document manager inside my controller, and everything went well until I tried to save the document. Error with this error:
"[Semantic error] The annotations" @Document "in the SdsCore \ Document \ User class have never been imported."
It seems that the failure in this line is DocParser.php if ('\\' !== $name[0] && !$this->classExists($name)) {
It fails because $name = 'Document'
, and the imported annotation class is 'Doctrine\ODM\MongoDB\Mapping\Annotations\Doctrine'
Here is my document class:
namespace SdsCore\Document; class User { private $id; private $name; private $firstname; public function get($property) { $method = 'get'.ucfirst($property); if (method_exists($this, $method)) { return $this->$method(); } else { $propertyName = $property; return $this->$propertyName; } } public function set($property, $value) { $method = 'set'.ucfirst($property); if (method_exists($this, $method)) { $this->$method($value); } else { $propertyName = $property; $this->$propertyName = $value; } }
}
Here is my action controller:
public function indexAction() { $dm = $this->documentManager; $user = new User(); $user->set('name', 'testname'); $user->set('firstname', 'testfirstname'); $dm->persist($user); $dm->flush; return new ViewModel(); }
source share