大家好,我是Symfony的新手,并使用sonata admin bundle制作网页。我想从sonata admin添加adesigns calendar bundle上的事件,但是当我扩展EventEntity类并尝试添加新事件时,它给了我以下错误:
类型错误:参数2传递给 AppBundle \ Entity \ Schedule :: __ construct()必须是。的实例 DateTime,无给定,在/path/to/project/vendor/sonata-project/doctrine-orm-admin-bundle/Model/ModelManager.php中调用 在第509行
我知道它会导致DateTime的类型,但我不知道如何解决它。
这是扩展代码:
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use ADesigns\CalendarBundle\Entity\EventEntity;
/**
* Schedule
*
* @ORM\Table(name="schedule")
* @ORM\Entity(repositoryClass="AppBundle\Repository\ScheduleRepository")
*/
class Schedule extends EventEntity {
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
* @ORM\Column(name="title", type="string", length=255)
*/
protected $title;
/**
* @var string
* @ORM\Column(name="url", type="string", length=255, nullable=true)
*/
protected $url;
/**
* @var string
* @ORM\Column(name="bgColor", type="string", length=255)
*/
protected $bgColor;
/**
* @var string
* @ORM\Column(name="fgColor", type="string", length=255)
*/
protected $fgColor;
/**
* @var string
* @ORM\Column(name="cssClass", type="string", length=255, nullable=true)
*/
protected $cssClass;
/**
* @var bool
* @ORM\Column(name="allDay", type="boolean")
*/
protected $allDay;
/**
* @var DateTime
* @ORM\Column(name="startDatetime", type="datetime")
*/
protected $startDatetime;
/**
* @var DateTime
* @ORM\Column(name="endDatetime", type="datetime")
*/
protected $endDatetime;
public function __construct($title, \DateTime $startDatetime, \DateTime $endDatetime = null, $allDay = false, $hall) {
parent::__construct($title, $startDatetime, $endDatetime, $allDay);
$this->hall = $hall;
}
/**
* Get id
*
* @return int
*/
public function getId() {
return $this->id;
}
}