我将symfony 4与奏鸣曲管理面板配合使用。当我尝试从前端(而非管理面板)保留我的实体时,出现以下错误:
在链配置的名称空间MsgPhp中找不到类'Doctrine \ Common \ Collections \ ArrayCollection', Sonata \ NotificationBundle \ Entity,App \ Entity
但是,如果合并(更新),则不会显示该错误。可能是什么问题?我完全迷路了。
我粘贴在我的实体下面:
<?php
namespace App\Entity;
use App\Entity\User\User;
use App\Entity\Country;
use App\Entity\Sex;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\DoctorDataRepository")
*/
class DoctorData
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=100)
*/
private $lastname;
/**
* @ORM\Column(type="string", length=100)
*/
private $firstname;
/**
* @ORM\Column(type="string", length=11)
*/
private $amka;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $fatherName;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $motherName;
/**
* @ORM\Column(type="string", length=100)
*/
private $citizenship;
/**
* @ORM\Column(type="string", length=15)
*/
private $identity;
/**
* @ORM\Column(type="string" , length=15, nullable=true)
*/
private $identityType;
/**
* @ORM\Column(type="smallint", nullable=true)
*/
private $identityYear;
/**
* @ORM\Column(type="date")
*/
private $birthDate;
/**
* @ORM\Column(type="string", length=100)
*/
private $birthRegion;
// /**
// * @ORM\OneToOne(targetEntity="App\Entity\User\User", inversedBy="doctorData", cascade={"persist", "remove"})
// * @ORM\JoinColumn(nullable=false)
// */
// private $user;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Country")
* @ORM\JoinColumn(nullable=false)
*/
private $country;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Sex")
* @ORM\JoinColumn(nullable=false)
*/
private $sex;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\NotBlank()
*/
private $address;
/**
* @ORM\Column(type="string", length=15, nullable=true)
*/
private $zipcode;
/**
* @ORM\Column(type="string", length=30, nullable=true)
*/
private $phone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email;
/**
* @ORM\Column(type="string", length=9, nullable=true)
*/
private $afm;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $birthPerfecture;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $addressMunicipal;
/**
* @ORM\Column(type="string", length=30, nullable=true)
*/
private $phoneTwo;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $hasNHS;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ApplicationPositions", mappedBy="doctor")
*/
private $applicationPositions;
/**
* @ORM\OneToMany(targetEntity="App\Entity\WorkExperience", mappedBy="DoctorData")
*/
private $workExperiences;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Document", mappedBy="doctorData", orphanRemoval=true)
*/
private $documents;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\County")
*/
private $AddressCounty;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Degree", mappedBy="doctorData")
*/
private $doctorDegrees;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Application", mappedBy="doctorData")
*/
private $applications;
/**
* @ORM\OneToMany(targetEntity="App\Entity\SelectedPositions", mappedBy="doctorData", orphanRemoval=true)
*/
private $selectedPositions;
/**
* @ORM\Column(type="boolean")
*/
private $hasPublicSector;
public function __construct()
{
$this->applicationPositions = new ArrayCollection();
$this->workExperiences = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->doctorDegrees = new ArrayCollection();
$this->applications = new ArrayCollection();
$this->selectedPositions = new ArrayCollection();
}
public function getId()
{
return $this->id;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getAmka(): ?string
{
return $this->amka;
}
public function setAmka(string $amka): self
{
$this->amka = $amka;
return $this;
}
public function getFatherName(): ?string
{
return $this->fatherName;
}
public function setFatherName(?string $fatherName): self
{
$this->fatherName = $fatherName;
return $this;
}
public function getMotherName(): ?string
{
return $this->motherName;
}
public function setMotherName(?string $motherName): self
{
$this->motherName = $motherName;
return $this;
}
public function getCitizenship(): ?string
{
return $this->citizenship;
}
public function setCitizenship(string $citizenship): self
{
$this->citizenship = $citizenship;
return $this;
}
public function getIdentity(): ?string
{
return $this->identity;
}
public function setIdentity(string $identity): self
{
$this->identity = $identity;
return $this;
}
public function getBirthDate(): ?\DateTimeInterface
{
return $this->birthDate;
}
public function setBirthDate(\DateTimeInterface $birthDate): self
{
$this->birthDate = $birthDate;
return $this;
}
public function getBirthRegion(): ?string
{
return $this->birthRegion;
}
public function setBirthRegion(string $birthRegion): self
{
$this->birthRegion = $birthRegion;
return $this;
}
// public function getUser(): ?User
// {
// return $this->user;
// }
// public function setUser(User $user): self
// {
// $this->user = $user;
// return $this;
// }
public function getCountry(): ?Country
{
return $this->country;
}
public function setCountry(?Country $country): self
{
$this->country = $country;
return $this;
}
public function getSex(): ?Sex
{
return $this->sex;
}
public function setSex(?Sex $sex): self
{
$this->sex = $sex;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getZipcode(): ?string
{
return $this->zipcode;
}
public function setZipcode(?string $zipcode): self
{
$this->zipcode = $zipcode;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getAfm(): ?string
{
return $this->afm;
}
public function setAfm(?string $afm): self
{
$this->afm = $afm;
return $this;
}
public function getIdentityType(): ?string
{
return $this->identityType;
}
public function setIdentityType(string $identityType): self
{
$this->identityType = $identityType;
return $this;
}
public function getIdentityYear(): ?int
{
return $this->identityYear;
}
public function setIdentityYear(?int $identityYear): self
{
$this->identityYear = $identityYear;
return $this;
}
public function getBirthPerfecture(): ?string
{
return $this->birthPerfecture;
}
public function setBirthPerfecture(?string $birthPerfecture): self
{
$this->birthPerfecture = $birthPerfecture;
return $this;
}
public function getAddressMunicipal(): ?string
{
return $this->addressMunicipal;
}
public function setAddressMunicipal(?string $addressMunicipal): self
{
$this->addressMunicipal = $addressMunicipal;
return $this;
}
public function getPhoneTwo(): ?string
{
return $this->phoneTwo;
}
public function setPhoneTwo(?string $phoneTwo): self
{
$this->phoneTwo = $phoneTwo;
return $this;
}
public function getHasNHS(): ?bool
{
return $this->hasNHS;
}
public function setHasNHS(?bool $hasNHS): self
{
$this->hasNHS = $hasNHS;
return $this;
}
/**
* @return Collection|ApplicationPositions[]
*/
public function getApplicationPositions(): Collection
{
return $this->applicationPositions;
}
public function addApplicationPosition(ApplicationPositions $applicationPosition): self
{
if (!$this->applicationPositions->contains($applicationPosition)) {
$this->applicationPositions[] = $applicationPosition;
$applicationPosition->setDoctor($this);
}
return $this;
}
public function removeApplicationPosition(ApplicationPositions $applicationPosition): self
{
if ($this->applicationPositions->contains($applicationPosition)) {
$this->applicationPositions->removeElement($applicationPosition);
// set the owning side to null (unless already changed)
if ($applicationPosition->getDoctor() === $this) {
$applicationPosition->setDoctor(null);
}
}
return $this;
}
/**
* @return Collection|WorkExperience[]
*/
public function getWorkExperiences(): Collection
{
return $this->workExperiences;
}
public function addWorkExperience(WorkExperience $workExperience): self
{
if (!$this->workExperiences->contains($workExperience)) {
$this->workExperiences[] = $workExperience;
$workExperience->setDoctorData($this);
}
return $this;
}
public function removeWorkExperience(WorkExperience $workExperience): self
{
if ($this->workExperiences->contains($workExperience)) {
$this->workExperiences->removeElement($workExperience);
// set the owning side to null (unless already changed)
if ($workExperience->getDoctorData() === $this) {
$workExperience->setDoctorData(null);
}
}
return $this;
}
/**
* @return Collection|Document[]
*/
public function getDocuments(): Collection
{
return $this->documents;
}
public function addDocument(Document $document): self
{
if (!$this->documents->contains($document)) {
$this->documents[] = $document;
$document->setDoctorData($this);
}
return $this;
}
public function removeDocument(Document $document): self
{
if ($this->documents->contains($document)) {
$this->documents->removeElement($document);
// set the owning side to null (unless already changed)
if ($document->getDoctorData() === $this) {
$document->setDoctorData(null);
}
}
return $this;
}
public function getAddressCounty(): ?County
{
return $this->AddressCounty;
}
public function setAddressCounty(?County $AddressCounty): self
{
$this->AddressCounty = $AddressCounty;
return $this;
}
/**
* @return Collection|Degree[]
*/
public function getDoctorDegrees(): Collection
{
return $this->doctorDegrees;
}
public function addDoctorDegree(Degree $doctorDegree): self
{
if (!$this->doctorDegrees->contains($doctorDegree)) {
$this->doctorDegrees[] = $doctorDegree;
$doctorDegree->setDoctorData($this);
}
return $this;
}
public function removeDoctorDegree(Degree $doctorDegree): self
{
if ($this->doctorDegrees->contains($doctorDegree)) {
$this->doctorDegrees->removeElement($doctorDegree);
// set the owning side to null (unless already changed)
if ($doctorDegree->getDoctorData() === $this) {
$doctorDegree->setDoctorData(null);
}
}
return $this;
}
/**
* @return Collection|Application[]
*/
public function getApplications(): Collection
{
return $this->applications;
}
public function addApplication(Application $application): self
{
if (!$this->applications->contains($application)) {
$this->applications[] = $application;
$application->setDoctorDataId($this);
}
return $this;
}
public function removeApplication(Application $application): self
{
if ($this->applications->contains($application)) {
$this->applications->removeElement($application);
// set the owning side to null (unless already changed)
if ($application->getDoctorDataId() === $this) {
$application->setDoctorDataId(null);
}
}
return $this;
}
/**
* @return Collection|SelectedPositions[]
*/
public function getSelectedPositions(): Collection
{
return $this->selectedPositions;
}
public function addSelectedPosition(SelectedPositions $selectedPosition): self
{
if (!$this->selectedPositions->contains($selectedPosition)) {
$this->selectedPositions[] = $selectedPosition;
$selectedPosition->setDoctorData($this);
}
return $this;
}
public function removeSelectedPosition(SelectedPositions $selectedPosition): self
{
if ($this->selectedPositions->contains($selectedPosition)) {
$this->selectedPositions->removeElement($selectedPosition);
// set the owning side to null (unless already changed)
if ($selectedPosition->getDoctorData() === $this) {
$selectedPosition->setDoctorData(null);
}
}
return $this;
}
public function getHasPublicSector(): ?bool
{
return $this->hasPublicSector;
}
public function setHasPublicSector(bool $hasPublicSector): self
{
$this->hasPublicSector = $hasPublicSector;
return $this;
}
}
预先感谢