Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ProductFilterProcessor implements \Pd\DataGridModule\DataSource\FilterProcessor
- {
- /**
- * @var \Pd\DataGridModule\DataSource\BaseFilterProcessor
- */
- private $baseFilterProcessor;
- public function __construct()
- {
- $this->baseFilterProcessor = new \Pd\DataGridModule\DataSource\BaseFilterProcessor();
- }
- public function process(\Ublaboo\DataGrid\Filter\Filter $filter): array
- {
- switch ($filter->getKey()) {
- case 'isOnlyStoreMode':
- return $this->processIsOnlyStoreMode($filter);
- default:
- try {
- return $this->baseFilterProcessor->process($filter);
- } catch (\Pd\DataGridModule\Exception\DataSourceUnrecognizedFilterException $exception) {
- return [];
- }
- }
- }
- private function processIsOnlyStoreMode(\Ublaboo\DataGrid\Filter\Filter $filter): array
- {
- return [
- 'callable' => [
- function (\Dibi\Fluent $dibiFluent) use ($filter) {
- $dibiFluent
- ->where(((bool) $filter->getValue() ? 'NOT ' : NULL) . 'EXISTS (SELECT 1 FROM `product_item_text` WHERE `item_id` = `product_item`.`id` AND `isOnlyStoreMode` = "0" AND `web_id` = `product_text`.`web_id`)');
- },
- ],
- ];
- }
- }
Add Comment
Please, Sign In to add comment