【发布时间】:2017-10-01 01:33:29
【问题描述】:
我使用 Sonata Admin 包。我收到错误:无法创建对象:PizzaBundle\Entity\Promotion。我做了一个促销实体:
/**
* @ORM\Entity
* @ORM\Table(name="promotion")
*/
class Promotion {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=100)
*/
private $title;
/**
* @ORM\Column(type="string")
*/
private $description;
/**
* @ORM\Column(type="blob")
*/
private $image;
/**
* @ORM\Column(type="date")
*/
private $dataStart;
/**
* @ORM\Column(type="date")
*/
private $dataEnd;
PromotionAdmin.php
public function configureFormFields(FormMapper $formMapper) {
$formMapper
->add('title', 'text')
->add('description', 'text')
->end()
->with('Zdjęcie')
->add('image', 'file', ['required' => false])
->add('dataStart', 'date')
->add('dataEnd', 'date')
->end();
}
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('title')
->add('description')
->add('image')
->add('dataStart')
->add('dataEnd')
;
}
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('title')
->addIdentifier('description')
->addIdentifier('image')
->addIdentifier('dataStart')
->addIdentifier('dataEnd')
;
}
}
我的 services.yml
admin.promotion:
class: PizzaBundle\Admin\PromotionAdmin
arguments: [~, PizzaBundle\Entity\Promotion, ~]
tags:
- { name: sonata.admin, manager_type: orm, label: Promotion }
我的代码没有问题。我认为这是实体中类型变量 Image 的问题。如果这是 blob 类型的错误,请帮助解决问题。
【问题讨论】:
-
应该有异常的日志行,在profiler中查看。
-
我关于异常的帖子已关闭。
标签: php symfony doctrine-orm sonata-admin sonata