我想在服务中使用验证。
服务.yml:
AppBundle\Service\BookingCreateService:
arguments: [ "@doctrine.orm.entity_manager" , "@service_container"]
public: true
状态实体:
/**
* @var string
* @ORM\Column(name="Status", type="string", length=35)
* @Assert\Length(min="30", minMessage="error")
*/
private $status;
预订创建服务:
class BookingCreateService
{
protected $em;
public function __construct(EntityManager $em)
{
$this->em = $em;
}
public function create()
{
$a= new Status();
$a->setStatus("222");
$this->em->persist($a);
$this->em->flush();
}
}
我希望将有关不满足验证条件的消息从服务发送到控制器。然后到树枝模板。我已经阅读了文档,但我不知道如何去做:(