evilband7/doctrine-data

将SpringData特性引入PHP

0.1.1 2016-09-14 19:05 UTC

This package is not auto-updated.

Last update: 2024-09-23 13:32:47 UTC


README

通过分页支持扩展doctrine仓库功能。(灵感来源于SpringData项目。)

特性

  • 创建不带实现(仅接口)的自己的Repository类
  • 也支持自定义实现。
  • 支持使用强类型分页存根(DoctrineData\Pagination\*)进行分页
  • 使Doctrine2 Repository更强大。
  • 默认不支持Doctrine2魔术方法(您需要在接口中定义该方法。因为我们专注于维护。人们应该如何知道当前项目中正在使用哪些魔术方法。)

状态

  • 开发中。
  • 很快将可用。
  • 请随意分支并提交pull请求。xD

基本Repository接口

 interface EmployeeRepository extends DoctrineDataRepositoryInterface
 {
    /** @Query("select e from Employee e where e.name = ?1") */
    public function findByDepartmentId(int $departmentId, PageableInterface $pageable);
 }
 
 /* @var $repository EmployeeRepository */
 /* @var $page PageInterface */
 
 $pageRequest = new PageRequest(1,10);
 $repository = $em->getRepository(Employee::class);     
 $page = $repository->findByDepartmentId(1, $pageRequest);
 
 foreach($page as $emp){
    echo 'Name: ' . $emp->getName() ;
 }