定制 padam87/search-bundle 二次开发

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

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

padam87/search-bundle

最新稳定版本:v2.0.1

Composer 安装命令:

composer require padam87/search-bundle

包简介

Symfony2 SearchBundle

README 文档

README

Build Status Coverage Status Scrutinizer Quality Score SensioLabsInsight Latest Stable Version Total Downloads Latest Unstable Version License

Search Bundle

Search bundle for Symfony2. Use entities, collections for search directly. Great for handling complex search forms.

1. Examples

1.1 Simple

$fm = $this->get('padam87_search.filter.manager');
$filter = new Filter($data, 'YourBundle:Entity', 'alias');
$qb = $fm->createQueryBuilder($filter);

$data can be an array, an entity, or even a doctrine collection.

You can add your own converter to handle any type of data.

1.2 Joins

$fm = $this->get('padam87_search.filter.manager');
$filter1 = new Filter($data1, 'YourBundle:Entity1', 'alias1');
$filter2 = new Filter($data2, 'YourBundle:Entity2', 'alias2');
$qb = $fm->joinToQueryBuilder($filter2, $fm->createQueryBuilder($filter1), 'associationName');

'associationName' is the name of the relation in your entity, eg 'users'

1.3 Collection valued associations

$fm = $this->get('padam87_search.filter.manager');
$filter = new Filter($data, 'YourBundle:Entity', 'alias');
$qb = $fm->createQueryBuilder($filter);

When $data is an entity, it can have *ToMany associations. By default, the bundle assumes OR relationship between the elements of the collection. To change that, you can use the 2nd parameter of $fm->createQueryBuilder:

$fm = $this->get('padam87_search.filter.manager');
$filter = new Filter($data, 'YourBundle:Entity', 'alias');
$qb = $fm->createQueryBuilder($filter, array(
    'relationName' => 'AND'
));

1.4 Operators

$data = array(
    'integerField>=' => 10
    'stringFiled' => 'A*'
);
$filter = new Filter($data, 'YourBundle:Entity', 'alias');

The bundle will search for operators in the field names and values, and use the appropriate Expr.

For a nicer, and entity-compatible solution you can use the 4th parameter of the Filter to set default operators:

$filter = new Filter($data, 'YourBundle:Entity', 'alias', array(
    'integerField' => '>='
));

2. Installation

2.1. Composer

"padam87/search-bundle": "2.0.*",

2.2. AppKernel

$bundles = array(
	...
    new Padam87\SearchBundle\Padam87SearchBundle(),
);

统计信息

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

GitHub 信息

  • Stars: 8
  • Watchers: 3
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-11-15