tbn/query-builder-repository-generator-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

tbn/query-builder-repository-generator-bundle

Composer 安装命令:

composer require tbn/query-builder-repository-generator-bundle

包简介

Generate filters for queryBuilder in a repository

README 文档

README

The QueryBuilderRepositoryGeneratorBundle generates Repositories in the repository folders

The functions allow to filter on the columns of the entity with a query builder.

See the create queries section for an example.

Installation

Import the bundle using composer

composer require --dev "tbn/query-builder-repository-generator-bundle"

Import the bundle in your AppKernel

if ('dev' === $this->getEnvironment()) {
    $bundles[] = new Tbn\QueryBuilderRepositoryGeneratorBundle\QueryBuilderRepositoryGeneratorBundle();
}

Configuration

Mandatory configuration

Add the bundles you want:

	query_builder_repository_generator:
		bundles:
    		- "<<YourBundleName>>"

Those bundles will have the repositories generated in the Repository directory of the bundles. Check the content by yourself.

Optional configuration

	query_builder_repository_generator:
		templates:
			top_repository: "QueryBuilderRepositoryGeneratorBundle:Generator:TopRepositoryTemplate.html.twig"
			column: "QueryBuilderRepositoryGeneratorBundle:Generator:ColumnTemplate.html.twig"
			association: "QueryBuilderRepositoryGeneratorBundle:Generator:AssociationTemplate.html.twig"
			bottom_repository: "QueryBuilderRepositoryGeneratorBundle:Generator:BottomRepositoryTemplate.html.twig"
	mapping:
		- 'AppBundle\Entity\Member':
			querybuilder_name: 'memberEntity' # the name of the entity used in the queryBuilder

The repository extends

You can specify a class to extends for each entity.

	repositories_extensions:
		- "AcmeBundle\Entity\Item": #the entity class
			extension_class: "\\Gedmo\\Tree\\Entity\\Repository\\MaterializedPathRepository" #the class to extends

The templates used by the generator can be set with these configurations.

	top_repository => The beginning of the repository file
	column => The template used for each column
	extra_column => A custom template of your choice
	bottom_repository => The end of the repository file

The extra_column template have the following variables:

	'entity' => $tableName,
	'entityDql' => lcfirst($tableName),
	'column' => ucfirst($columnName),
	'columnDql' => $columnName

Use generated repositories

In your Entity Repository, extends the generated repository.

	class UserRepository extends UserRepositoryBase

Your repository has now some predefined function like "filterById", "filterInId" for all the columns.

Create queries

Example:

	$qb = $this->createQueryBuilder('document');

	//filter on current user (where XX = YY)
   DocumentRepository::filterByUser($qb, $user);
   //filter on the extension list (where xxx IN () )
   DocumentRepository::filterInExtension($qb, $extensionList);

   //Join the tag entity
   $qb->join('document.tags', 'tag');
   //filter on the tag entity
   TagRepository::filterById($qb, $tagButton);

Regenerate files

Run the command:

php app/console qbrg:generate

tbn/query-builder-repository-generator-bundle 适用场景与选型建议

tbn/query-builder-repository-generator-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.84k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2015 年 03 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 tbn/query-builder-repository-generator-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tbn/query-builder-repository-generator-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 tbn/query-builder-repository-generator-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 9.84k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 27
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-03-19