PropertyAccessor symfony 4

时间:2018-10-18 05:37:02

标签: sonata-admin symfony4

在奏鸣曲管理员中,我尝试创建实体“应用程序”的形式,其中包括单独的实体。但是在管理部分中,出现以下错误:

  

PropertyAccessor需要一个对象图或数组来进行操作,   但在尝试遍历路径时发现类型为“ NULL”   属性“ ArmyCondition”中的“ doctorArmy.ArmyCondition”。

我发现了类似的问题here,但我不明白应该在__construct函数中以及在哪个__construct函数中解决什么问题。我还应该检查其他东西吗?我使用Symfony4。

应用程序:

<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="App\Repository\DoctorArmyRepository")
 */
class DoctorArmy
{
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\ManyToOne(targetEntity="App\Entity\DoctorData")
     * @ORM\JoinColumn(nullable=false)
     */
    private $Doctor;

    /**
     * @ORM\OneToOne(targetEntity="App\Entity\Application", cascade={"persist", "remove"})
     * @ORM\JoinColumn(nullable=false)
     */
    private $Application;

    /**
     * @ORM\ManyToOne(targetEntity="App\Entity\ArmyCondition")
     * @ORM\JoinColumn(nullable=false)
     */
    private $ArmyCondition;

    /**
     * @ORM\Column(type="date", nullable=true)
     */
    private $DischargeDate;

    /**
     * @ORM\Column(type="date", nullable=true)
     */
    private $PostponeDate;

    public function getId()
    {
        return $this->id;
    }

    public function getDoctor(): ?doctorData
    {
        return $this->Doctor;
    }

    public function setDoctor(?doctorData $Doctor): self
    {
        $this->Doctor = $Doctor;

        return $this;
    }

    public function getApplication(): ?Application
    {
        return $this->Application;
    }

    public function setApplication(Application $Application): self
    {
        $this->Application = $Application;

        return $this;
    }

    public function getArmyCondition(): ?ArmyCondition
    {
        return $this->ArmyCondition;
    }

    public function setArmyCondition(?ArmyCondition $ArmyCondition): self
    {
        $this->ArmyCondition = $ArmyCondition;

        return $this;
    }

    public function getDischargeDate(): ?\DateTimeInterface
    {
        return $this->DischargeDate;
    }

    public function setDischargeDate(?\DateTimeInterface $DischargeDate): self
    {
        $this->DischargeDate = $DischargeDate;

        return $this;
    }

    public function getPostponeDate(): ?\DateTimeInterface
    {
        return $this->PostponeDate;
    }

    public function setPostponeDate(?\DateTimeInterface $PostponeDate): self
    {
        $this->PostponeDate = $PostponeDate;

        return $this;
    }
}

ArmyCondition:

<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="App\Repository\DoctorArmyRepository")
 */
class DoctorArmy
{
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\ManyToOne(targetEntity="App\Entity\DoctorData")
     * @ORM\JoinColumn(nullable=false)
     */
    private $Doctor;

    /**
     * @ORM\OneToOne(targetEntity="App\Entity\Application", cascade={"persist", "remove"})
     * @ORM\JoinColumn(nullable=false)
     */
    private $Application;

    /**
     * @ORM\ManyToOne(targetEntity="App\Entity\ArmyCondition")
     * @ORM\JoinColumn(nullable=false)
     */
    private $ArmyCondition;

    /**
     * @ORM\Column(type="date", nullable=true)
     */
    private $DischargeDate;

    /**
     * @ORM\Column(type="date", nullable=true)
     */
    private $PostponeDate;

    public function getId()
    {
        return $this->id;
    }

    public function getDoctor(): ?doctorData
    {
        return $this->Doctor;
    }

    public function setDoctor(?doctorData $Doctor): self
    {
        $this->Doctor = $Doctor;

        return $this;
    }

    public function getApplication(): ?Application
    {
        return $this->Application;
    }

    public function setApplication(Application $Application): self
    {
        $this->Application = $Application;

        return $this;
    }

    public function getArmyCondition(): ?ArmyCondition
    {
        return $this->ArmyCondition;
    }

    public function setArmyCondition(?ArmyCondition $ArmyCondition): self
    {
        $this->ArmyCondition = $ArmyCondition;

        return $this;
    }

    public function getDischargeDate(): ?\DateTimeInterface
    {
        return $this->DischargeDate;
    }

    public function setDischargeDate(?\DateTimeInterface $DischargeDate): self
    {
        $this->DischargeDate = $DischargeDate;

        return $this;
    }

    public function getPostponeDate(): ?\DateTimeInterface
    {
        return $this->PostponeDate;
    }

    public function setPostponeDate(?\DateTimeInterface $PostponeDate): self
    {
        $this->PostponeDate = $PostponeDate;

        return $this;
    }
}

0 个答案:

没有答案