我的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 \ Entity \ Venue(为了举例而缩短):
type: entity
table: venues
manyToOne:
address:
targetEntity: AppBundle\Entity\Address
joinColumn:
name: address_id
referencedColumnName: id
nullable: false
cascade: ["persist"]
问题是我面临抛出异常:
注意:数组到字符串转换500内部服务器错误 - ContextErrorException 这里
$proxyCode = strtr($this->proxyClassTemplate, $venueholders);
(在第280行的vendor / doctrine / common / lib / Doctrine / Common / Proxy / ProxyGenerator.php中)。
当我删除关系时,一切正常,所以它告诉我地址实体存在某种问题。
我试图清除缓存 - 没有运气。映射对我来说没问题,getter / setter是正确的。
任何提示?
答案 0 :(得分:2)
您是否尝试完全重新安装供应商?我在您的问题中看到了一个问题:$proxyCode = strtr($this->proxyClassTemplate, $venueholders);
。
ProxyGenerator类的第280行应如下所示:https://github.com/doctrine/common/blob/master/lib/Doctrine/Common/Proxy/ProxyGenerator.php#L280
。
您是否尝试应用搜索&amp;什么机会替换你的代码?
答案 1 :(得分:1)
尝试使用column:
代替name:
postalCode:
column: postal_code
type: string
nullable: true