sidus / eav-filter-bundle
为 sidus/eav-model-bundle 和 sidus/filter-bundle 提供扩展,用于处理 EAV 模型
v3.0.0
2020-04-14 21:12 UTC
Requires
- sidus/eav-model-bundle: v1.3.*|dev-v1.3-dev
- sidus/filter-bundle: v3.0.*|dev-v3.0-dev
This package is auto-updated.
Last update: 2024-09-15 06:39:22 UTC
README
此包在 Sidus/FilterBundle 的基础上工作,并支持与 Sidus/EAVModelBundle 的兼容性。
安装
包设置
使用 composer 需要此包
$ composer require sidus/eav-filter-bundle "^1.3.5"
将包添加到 AppKernel.php
<?php /** * app/AppKernel.php */ class AppKernel { public function registerBundles() { $bundles = [ // ... // If not already enabled: new Sidus\EAVModelBundle\SidusEAVModelBundle(), new Sidus\FilterBundle\SidusFilterBundle(), // This bundle: new Sidus\EAVFilterBundle\SidusEAVFilterBundle(), // ... ]; } }
配置
查看 Sidus/FilterBundle 的基础配置文档。
只需使用 sidus.eav
提供者设置您的过滤器配置,并像这样设置 family
选项
sidus_filter: configurations: my_configuration: provider: sidus.eav # Tells the system to use the EAV filter engine options: family: News # Required to select the proper data source sortable: - id - label - publicationDate - publicationStatus - updatedAt default_sort: publicationDate: DESC filters: label: ~ publicationDate: type: date_range publicationStatus: type: choice category: type: autocomplete_data # Will display an autocomplete to the related EAV family
特定功能
choice
过滤器类型将自动从您的属性配置中加载选项。
目前,autocomplete_data
过滤器类型不支持与多个家族相关的属性。
此包为 PagerFanta 提供了特定的适配器,即支持 EAVModelBundle 中 OptimizedDataLoader 的 EAVAdapter。有关更多信息,请参阅此文档:EAV 查询优化
加载器的深度可以通过 loader_depth
选项进行配置
配置快速参考
sidus_filter: configurations: <configuration_code>: provider: sidus.eav # Required options: family: <FamilyCode> # Required # Optional options loader_depth: <int> # Default 2 query_context: <array> # If you want to inject a custom context (or part of it) statically for the query use_global_context: <bool> # Merge the query_context with the global context for the query # (the results always use the global context by default) result_context: <array> # Same as before but for the results (will inject this in Data::setCurrentContext)