Reputation: 321
I have a big problem with one of my entities in my Symfony project.
Some code first: Address entity
<?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;
}
}
Address entity mapping:
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
Venue entity mapping: AppBundle\Entity\Venue (shortened for the sake of example):
type: entity
table: venues
manyToOne:
address:
targetEntity: AppBundle\Entity\Address
joinColumn:
name: address_id
referencedColumnName: id
nullable: false
cascade: ["persist"]
The problem is that I face an exception being thrown:
Notice: Array to string conversion 500 Internal Server Error - ContextErrorException here
$proxyCode = strtr($this->proxyClassTemplate, $venueholders);
(in vendor/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php at line 280).
When I remove the relation, everything works correctly so it tells me there's some kind of issue with Address entity.
I've tried to clear the cache - no luck. Mapping looks ok to me, getters/setters are correct.
Any tips?
Upvotes: 2
Views: 962
Reputation: 1504
Did you try to reinstall your vendors completely? I see one issue in your question: $proxyCode = strtr($this->proxyClassTemplate, $venueholders);
.
Line 280 of ProxyGenerator class should look like this: https://github.com/doctrine/common/blob/master/lib/Doctrine/Common/Proxy/ProxyGenerator.php#L280
.
Did you try to apply search & replace on your code by any chance?
Upvotes: 2
Reputation: 6922
Try column:
instead of name:
postalCode:
column: postal_code
type: string
nullable: true
Upvotes: 1