定制 infinite-networks/specifications 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

infinite-networks/specifications

Composer 安装命令:

composer require infinite-networks/specifications

包简介

A specifications library for the Doctrine ORM

README 文档

README

This library is a base set of objects following the Specification pattern and based on a blog post about taming Doctrines EntityRepository classes.

http://www.whitewashing.de/2013/03/04/doctrine_repositories.html

How to use this library

This library adds 2 methods to the base EntityRepository class, match and matchOne, which both accept a specification that will build a query builder. Developers need to implement specifications that meet their domain requirements, and each specification must implement the Infinite\Specification\ORM\Specification interface.

An example of what using this library could look like:

    use Infinite\Specification\ORM as Spec;

    $repository = $managerRegistry->getRepository('Entity\User');

    // Retrieve any enabled users, ordered by username
    $enabledUsersSpec = new Spec\Sort(array('username' => 'ASC'), new Spec\AndX(array(
        new Spec\Equals('enabled', 1)
    ));
    $enabledUsers = $repository->match($enabledUsersSpec);

    // Count enabled users
    $countEnabledUsersSpec = new Spec\SingleScalar(new Spec\Count(new Spec\Equals('enabled', 1)));
    $enabledUsersCount = $repository->matchOne($countEnabledUsersSpec);

Doctrine must be configured to use a different base EntityRepository class, and any EntityRepositories implemented in your application must use the EntityRepository class defined in this library as their base class.

To define a different EntityRepository base class in Symfony2, add the following configuration:

doctrine:
    orm:
        default_repository_class: Infinite\Specification\ORM\EntityRepository

统计信息

  • 总下载量: 516
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 4
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-07-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固