2015-01-16 35 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