English 中文(简体)
Anotations namespace notloaded DoctrineMongoODMModule for Zend Framework 2
原标题:Annotations Namespace not loaded DoctrineMongoODMModule for Zend Framework 2

我把Doctrine MongoODM模块装上Zf2。 我已把文件管理员带往我的控制人,直到我试图坚持文件。 它没有这一错误:

“[原文] SdsCoreDocument中“@Document”的说明 用户永远不会进口......

It seems to fail on this line of DocParser.php if ( \ !== $name[0] && !$this->classExists($name)) {

它之所以失败,是因为<代码> 姓名 = 文件,而进口通知类别为。 DoctrineODMMongoDBMapping Annualotations Doctrine

我的文件类别如下:

namespace SdsCoreDocument;

/** @Document */
class User
{

/** 
 * @Id(strategy="UUID") 
 */
private $id;

/** 
 * @Field(type="string") 
 */
private $name;

/** 
 * @Field(type="string") 
 */
private $firstname;

public function get($property) 
{
    $method =  get .ucfirst($property);
    if (method_exists($this, $method))
    {
        return $this->$method();
    iii else {
        $propertyName = $property;
        return $this->$propertyName;
    iii           
iii

public function set($property, $value) 
{
    $method =  set .ucfirst($property);
    if (method_exists($this, $method))
    {
        $this->$method($value);
    iii else {
        $propertyName = $property;                
        $this->$propertyName = $value;
    iii
iii    

iii

我的行动控制者是:

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();
iii  
最佳回答

I didn t yet work on the DoctrineMongoODMModule, but I ll get to it next week. Anyway, you are still using the "old way" of loading annotations. Most of the doctrine projects are now using DoctrineCommonAnnotationsAnnotationReader, while your @AnnotationName tells me that you were using the DoctrineCommonAnnotationsSimpeAnnotationReader. You can read more about it at the DoctrineCommon documentation

因此,如何确定您的文件:

<?php
namespace SdsCoreDocument;

use DoctrineODMMongoDBMappingAnnotations as ODM;

/** @ODMDocument */
class User
{

    /** 
     * @ODMId(strategy="UUID") 
     */
    private $id;

    /** 
     * @ODMField(type="string") 
     */
    private $name;

    /** 
     * @ODMField(type="string") 
     */
    private $firstname;

    /* etc */
}
问题回答

暂无回答




相关问题
Zend and static class properties

I m trying to assign a value to a static class property when defining it: namespace Base; abstract class Skeleton { protected static $entityManager = end_Registry::get("EntityManager"); ......

require_once missing doctrine zend framework

I m integrating doctrine with Zend Framework. I ve hit an error thrown from cli. It seems Zend_Application_Bootstrap_Bootstrap does not have a require_once for ...

doctrine: QueryBuilder vs createQuery?

In Doctrine you can create DQL in 2 ways: EntityManager::createQuery: $query = $em->createQuery( SELECT u FROM MyProjectModelUser u WHERE u.id = ?1 ); QueryBuilder: $qb->add( select , u ) ...

热门标签