在 Symfony2 中,当我运行命令时,bin/vendors install
我收到以下消息:
?? src/Symfony/Component/Validator/Constraints/Alphanumeric.php
?? src/Symfony/Component/Validator/Constraints/AlphanumericValidator.php
?? src/Symfony/Component/Validator/Constraints/GreaterThan.php
?? src/Symfony/Component/Validator/Constraints/GreaterThanValidator.php
"symfony" has local modifications. Please revert or commit/push them before running this command again.
列出的文件是我按照此处的说明书条目创建的自定义约束验证器。
有没有办法更新 deps 文件而忽略我所做的更改?我的目标是安装一个新包,同时保留我创建的约束验证器文件。
更新:彼得的解决方案是正确的,唯一剩下的就是在实体中“使用”正确的命名空间,如下所示:
(代码中有西班牙语单词,我再次假设我在 DemoBundle 中只是为了保持一致性)
namespace Acme\DemoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Acme\DemoBundle\Component\Validator\Constraints as CustomAssert;
/**
* @ORM\Entity
*/
class Employee
{
//...
/**
* @ORM\Column(type="string", length=20)
* @Assert\NotBlank()
* @CustomAssert\Alphanumeric()
*/
protected $alfanum;
//...
}