2015-01-16 40 views
2

我的Symfony项目中有一个实体存在大问题。学说实体代理异常

某些代码第一: 地址实体

<?php 
namespace AppBundle\Entity; 
class Address 
{ 
/** 
* @var integer 
*/ 
private $id; 

/** 
* @var string 
*/ 
private $street; 

/** 
* @var string|null 
*/ 
private $postalCode; 

/** 
* @var string|null 
*/ 
private $city; 

/** 
* @var string|null 
*/ 
private $province; 

/** 
* @var float 
*/ 
private $latitude; 

/** 
* @var float 
*/ 
private $longtitude; 

/** 
* Get id 
* 
* @return integer 
*/ 
public function getId() 
{ 
    return $this->id; 
} 

/** 
* Set street 
* 
* @param string $street 
* @return Address 
*/ 
public function setStreet($street) 
{ 
    $this->street = $street; 

    return $this; 
} 

/** 
* Get street 
* 
* @return string 
*/ 
public function getStreet() 
{ 
    return $this->street; 
} 

/** 
* Set postalCode 
* 
* @param integer $postalCode 
* @return Address 
*/ 
public function setPostalCode($postalCode) 
{ 
    $this->postalCode = $postalCode; 

    return $this; 
} 

/** 
* Get postalCode 
* 
* @return integer 
*/ 
public function getPostalCode() 
{ 
    return $this->postalCode; 
} 

/** 
* Set city 
* 
* @param string $city 
* @return Address 
*/ 
public function setCity($city) 
{ 
    $this->city = $city; 

    return $this; 
} 

/** 
* Get city 
* 
* @return string 
*/ 
public function getCity() 
{ 
    return $this->city; 
} 

/** 
* Set province 
* 
* @param string $province 
* @return Address 
*/ 
public function setProvince($province) 
{ 
    $this->province = $province; 

    return $this; 
} 

/** 
* Get province 
* 
* @return string 
*/ 
public function getProvince() 
{ 
    return $this->province; 
} 

/** 
* Set latitude 
* 
* @param string $latitude 
* @return Address 
*/ 
public function setLatitude($latitude) 
{ 
    $this->latitude = $latitude; 

    return $this; 
} 

/** 
* Get latitude 
* 
* @return string 
*/ 
public function getLatitude() 
{ 
    return $this->latitude; 
} 

/** 
* Set longtitude 
* 
* @param string $longtitude 
* @return Address 
*/ 
public function setLongtitude($longtitude) 
{ 
    $this->longtitude = $longtitude; 

    return $this; 
} 

/** 
* Get longtitude 
* 
* @return string 
*/ 
public function getLongtitude() 
{ 
    return $this->longtitude; 
} 
} 

地址实体映射:

AppBundle\Entity\Address: 
type: entity 
table: addresses 

id: 
    id: 
     type: integer 
     generator: 
      strategy: AUTO 
fields: 
    street: 
     type: string 
     nullable: false 
    postalCode: 
     name: postal_code 
     type: string 
     nullable: true 
    city: 
     type: string 
     nullable: false 
    province: 
     type: string 
     nullable: true 
    latitude: 
     type: decimal 
     scale: 12 
     precision: 18 
     nullable: true 
    longtitude: 
     type: decimal 
     scale: 12 
     precision: 18 
     nullable: true 

地点实体映射: 的appbundle \实体\地点(缩短例如起见):

type: entity 
table: venues 
manyToOne: 
    address: 
     targetEntity: AppBundle\Entity\Address 
     joinColumn: 
      name: address_id 
      referencedColumnName: id 
     nullable: false 
     cascade: ["persist"] 

问题是我面对一个前ception被抛出:

通知:Array对字符串的转换500内部服务器错误 - ContextErrorException 这里$proxyCode = strtr($this->proxyClassTemplate, $venueholders);(在供应商/教义/普通/ LIB /学说/普通/代理/ ProxyGenerator.php在线路280)。

当我删除关系时,一切工作正常,所以它告诉我有Address实体的某种问题。

我试图清除缓存 - 没有运气。映射看起来对我来说没问题,getters/setters是正确的。

任何提示?

回答

2

你尝试完全重新安装你的供应商?我在你的问题中看到一个问题:$proxyCode = strtr($this->proxyClassTemplate, $venueholders);

ProxyGenerator类的第280行应如下所示:https://github.com/doctrine/common/blob/master/lib/Doctrine/Common/Proxy/ProxyGenerator.php#L280

你试过申请搜索&替换你的代码吗?

+0

是的!明白了!我用“场地”替换了“场所”,但我完全忘记了这一点,我确信我只将变化应用到了'src'目录!你们两个。 – user1854344

1

尝试column:代替name:

postalCode: 
     column: postal_code 
     type: string 
     nullable: true 
+0

感谢您的回答。不幸的是:( – user1854344

+0

@ user1854344你是否正确地分隔了元素? – acontell

+0

是的,我已经三重检查过它了,还有,检查实体获取者/设置者 – user1854344