尝试Map实体时出错
我有这门课
<?php
namespace Domain\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
class Restaurant
{
private $id;
private $uidentifier;
private $name;
private $address;
private $latitude;
private $longitude;
private $city_name;
private $popularityRate;
private $satisfactionRate;
private $averagePrice;
private $totalReviews;
private $segments;
public function __construct()
{
$this->segments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUidentifier(): ?string
{
return $this->uidentifier;
}
public function setUidentifier(string $uidentifier): self
{
$this->uidentifier = $uidentifier;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getLatitude(): ?string
{
return $this->latitude;
}
public function setLatitude(?string $latitude): self
{
$this->latitude = $latitude;
return $this;
}
public function getLongitude(): ?string
{
return $this->longitude;
}
public function setLongitude(?string $longitude): self
{
$this->longitude = $longitude;
return $this;
}
public function getPopularityRate(): ?string
{
return $this->popularityRate;
}
public function setPopularityRate(?string $popularityRate): self
{
$this->popularityRate = $popularityRate;
return $this;
}
public function getSatisfactionRate(): ?string
{
return $this->satisfactionRate;
}
public function setSatisfactionRate(?string $satisfactionRate): self
{
$this->satisfactionRate = $satisfactionRate;
return $this;
}
public function getAveragePrice(): ?string
{
return $this->averagePrice;
}
public function setAveragePrice(?string $averagePrice): self
{
$this->averagePrice = $averagePrice;
return $this;
}
public function getTotalReviews(): ?int
{
return $this->totalReviews;
}
public function setTotalReviews(?int $totalReviews): self
{
$this->totalReviews = $totalReviews;
return $this;
}
/**
* @return Collection|Segment[]
*/
public function getSegments(): Collection
{
return $this->segments;
}
public function addSegment(Segment $segment): self
{
if (!$this->segments->contains($segment)) {
$this->segments[] = $segment;
$segment->addRestaurant($this);
}
return $this;
}
public function removeSegment(Segment $segment): self
{
if ($this->segments->contains($segment)) {
$this->segments->removeElement($segment);
$segment->removeRestaurant($this);
}
return $this;
}
}
并且该Map文件
Domain\Restaurant:
type: entity
repositoryClass: Domain\Repository\RestaurantRepository
fields:
id:
id: true
type: integer
generator:
strategy: AUTO
uidentifier:
type: string
length: 150
nullable: false
name:
type: string
length: 255
nullable: true
address:
type: string
length: 255
nullable: true
latitude:
type: decimal
nullable: true
precision: 13
scale: 10
longitude:
type: decimal
nullable: true
precision: 14
scale: 11
city_name:
type: string
nullable: true
popularityRate:
type: decimal
nullable: true
precision: 4
scale: 2
satisfactionRate:
type: decimal
nullable: true
precision: 4
scale: 2
averagePrice:
type: decimal
nullable: true
precision: 6
scale: 2
totalReviews:
type: integer
nullable: true
indexes:
NAME_IDX:
columns: [name]
uniqueConstraints:
IDX_UID:
columns: [uidentifier]
options:
collate: utf8_bin
manyToMany:
segments:
targetEntity: Domain\Entity\Segment
mappedBy: restaurants
cascade: ["persist"]
餐厅与线段的关系为0:M,我尝试使用关系Map实体,但出现此错误
Invalid mapping file 'Domain.Entity.Restaurant.orm.yml' for class 'Domain\Entity\Restaurant'.
我被卡住了,我不知道哪里出了问题,Map这个实体的正确方法是什么?任何人都可以看到问题,因为我不知道
1条答案
按热度按时间fumotvh31#
您遗漏了 entity 的部分名称空间。
更改此项:
对此: