symfony – Wie ändere ich die folgenden Kommentare in yml?
世界只因有你
世界只因有你 2017-05-16 16:44:02
0
1
407
/**
 * @ORM\Column(type="string", length=255)
 *
 * @Assert\NotBlank(message="Please enter your name.", groups={"Registration", "Profile"})
 * @Assert\MinLength(limit="3", message="The name is too short.", groups={"Registration", "Profile"})
 * @Assert\MaxLength(limit="255", message="The name is too long.", groups={"Registration", "Profile"})
 */
protected $name;
世界只因有你
世界只因有你

Antworte allen(1)
滿天的星座

你的 Annotations 注释包含两个部分,实体字段 (Column) 和 验证规则 (Assert),在 Symfony 中需要分别定义到两个 Yml 文件中。

实体字段:

http://symfony.com/doc/current/book/doctrine.html

// src/AppBundle/Resources/onfig/doctrine/EntityName.orm.yml

AppBundle\Entity\EntityName:
    type: entity
    table: tableName
    // ...
    fields:
        name:
            type: string
            length: 255

验证规则:

http://symfony.com/doc/current/book/validation.html

// src/AppBundle/Resources/config/validation.yml

AppBundle\Entity\EntityName:
    properties:
        name:
            - NotBlank: { message: "Please enter your name.", groups: [Registration, Profile] }
            - MinLength: { limit: 3, message: "The name is too short.", groups: [Registration, Profile] }
            - MaxLength: { limit: 255, message: "The name is too long.", groups: [Registration, Profile] }
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage