delboy1978uk / person
一个可持久化的个人实体、存储库和服务。
v6.6.1
2024-05-06 16:57 UTC
Requires
- php: ^8.2
- delboy1978uk/bone-doctrine: ^2.0
- delboy1978uk/country: ^2.0
Requires (Dev)
- dev-master
- v6.6.1
- v6.6.0
- v6.5.5
- v6.5.4
- v6.5.3
- v6.5.2
- v6.5.1
- v6.5.0
- v6.4.2
- v6.4.1
- v6.4.0
- v6.3.5
- v6.3.4
- v6.3.3
- v6.3.2
- v6.3.1
- v6.3.0
- v6.2.0
- v6.1.1
- v6.1.0
- v6.0.6
- v6.0.5
- v6.0.4
- v6.0.3
- v6.0.2
- v6.0.1
- v6.0.0
- v5.0.0
- v4.0.5
- v4.0.4
- v4.0.3
- v4.0.2
- v4.0.1
- v4.0.0
- v3.1.0
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.0.0
- dev-7-use-attributes-instead-of-anotations
- dev-refactor/php81
- dev-dev-master
This package is auto-updated.
Last update: 2024-09-06 17:46:45 UTC
README
一个可持久化的个人实体、集合、存储库和服务,使用PHP编写。##安装
composer require delboy1978uk/person
设置和用法
您可以使用delboy1978uk/common,其中包含Doctrine2 ORM用于数据库持久化和Pimple作为依赖注入容器。您可以使用Del\Person\PersonPackage对象注册Person DIC项目。有关详细信息,请参阅delboy1978uk/common。
use Del\Commohn\ContainerService; use Del\Person\PersonPackage; $package = new PersonPackage(); ContainerService::getInstance()->registerToContainer($config);
个人实体
变量$code是一个DateTime对象。$country是一个Del\Entity\Country对象。
use Del\Person\Entity\Person; $del = new Person(); $del->setFirstname('Derek') ->setMiddlename('Stephen') ->setLastname('McLean) ->setAka('Del Boy') ->setDob($date) ->setBirthplace('Glasgow, Scotland') ->setCountry($country);
个人集合
或者我们可能称之为人。
Del\Person\Collection\PersonCollection扩展了ArrayIterator,并包含以下(附加)方法
$collection->update($person); // Updates the entity in the collection with fresh details $collection->append($person); // Adds an entity to the collection $collection->current(); // Retrieves the currently selected Person object $collection->findKey($person); // Retrieves the array offset key for any Person in the collection $collection->findById($id); // Retrieves a Person from the collection by their Id
个人服务
Del\Person\Service\PersonService包含一些处理个人对象的方法。
$svc->createFromArray($data); // Person object factory method accepting an array $svc->toArray($person); // Pass a Person, receive an array $svc->savePerson($person); // Saves a Person (adds or updates) to the database $svc->getRepository(); // Gets the Person Repository $svc->findByCriteria($criteria); // Finds results based upon your Criteria (see below) $svc->findOneByCriteria($criteria); // As above but for a single result
个人标准
使用此对象设置您的搜索标准。
use Del\Person\Criteria\PersonCriteria; $criteria = new PersonCriteria(); $criteria->setFirstname('Derek'); $criteria->setLastname('McLean'); $results = $svc->findByCriteria($criteria); // array of Person objects