nepada/phone-number-doctrine
最新稳定版本:v2.3.3
Composer 安装命令:
composer require nepada/phone-number-doctrine
包简介
Phone number type for Doctrine.
README 文档
README
Installation
Via Composer:
$ composer require nepada/phone-number-doctrine
Register the type in your bootstrap:
\Doctrine\DBAL\Types\Type::addType( \Brick\PhoneNumber\PhoneNumber::class, \Nepada\PhoneNumberDoctrine\PhoneNumberType::class );
In Nette with nettrine/dbal integration, you can register the types in your configuration:
dbal: connection: types: Brick\PhoneNumber\PhoneNumber: Nepada\PhoneNumberDoctrine\PhoneNumberType
Usage
PhoneNumberType maps database value to phone number value object (see brick/phonenumber for further details) and back. The phone number is stored using E164 format, i.e. a '+' sign followed by a series of digits comprising the country code and national number.
Example usage in the entity:
use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Brick\PhoneNumber\PhoneNumber; #[Entity] class Contact { #[Column(type: PhoneNumber::class, nullable: false)] private PhoneNumber $phoneNumber; public function getPhoneNumber(): PhoneNumber { return $this->phoneNumber; } }
Example usage in query builder:
$result = $repository->createQueryBuilder('foo') ->select('foo') ->where('foo.phoneNumber = :phoneNumber') // the parameter value is automatically normalized to +420123456789 ->setParameter('phoneNumber', '+420 123 456 789', \Brick\PhoneNumber\PhoneNumber::class) ->getQuery() ->getResult();
统计信息
- 总下载量: 36.9k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2018-06-09