delboy1978uk/person
最新稳定版本:v6.8.2
Composer 安装命令:
composer require delboy1978uk/person
包简介
A persistable person entity, repository, and service.
README 文档
README
A persistable Person Entity, Collection, Repository, and Service, written in PHP.
##Installation
Install via composer into your project:
composer require delboy1978uk/person
Setup and Usage
You can use delboy1978uk/common, which contains Doctrine2 ORM for database persistance, and Pimple as a dependency injection container. You can register the Person DIC items using the Del\Person\PersonPackage object. See delboy1978uk/common for details.
use Del\Commohn\ContainerService; use Del\Person\PersonPackage; $package = new PersonPackage(); ContainerService::getInstance()->registerToContainer($config);
The Person Entity
The $date variable is a DateTime object.
$country is a a Del\Entity\Country object.
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);
The Person Collection
Or people, as we might like to call it.
Del\Person\Collection\PersonCollection extends ArrayIterator and contains the following (additional) methods:
$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
The Person Service
Del\Person\Service\PersonService contains a few methods for dealing with Person objects.
$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
The Person Criteria
Set the criteria for your searches using this object.
use Del\Person\Criteria\PersonCriteria; $criteria = new PersonCriteria(); $criteria->setFirstname('Derek'); $criteria->setLastname('McLean'); $results = $svc->findByCriteria($criteria); // array of Person objects
统计信息
- 总下载量: 2.77k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-31