Guest User

Untitled

a guest
Feb 25th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. class ProductFilterProcessor implements \Pd\DataGridModule\DataSource\FilterProcessor
  2. {
  3. /**
  4. * @var \Pd\DataGridModule\DataSource\BaseFilterProcessor
  5. */
  6. private $baseFilterProcessor;
  7.  
  8. public function __construct()
  9. {
  10. $this->baseFilterProcessor = new \Pd\DataGridModule\DataSource\BaseFilterProcessor();
  11. }
  12.  
  13.  
  14. public function process(\Ublaboo\DataGrid\Filter\Filter $filter): array
  15. {
  16. switch ($filter->getKey()) {
  17. case 'isOnlyStoreMode':
  18. return $this->processIsOnlyStoreMode($filter);
  19. default:
  20. try {
  21. return $this->baseFilterProcessor->process($filter);
  22. } catch (\Pd\DataGridModule\Exception\DataSourceUnrecognizedFilterException $exception) {
  23. return [];
  24. }
  25. }
  26. }
  27.  
  28.  
  29. private function processIsOnlyStoreMode(\Ublaboo\DataGrid\Filter\Filter $filter): array
  30. {
  31. return [
  32. 'callable' => [
  33. function (\Dibi\Fluent $dibiFluent) use ($filter) {
  34. $dibiFluent
  35. ->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`)');
  36. },
  37. ],
  38. ];
  39. }
  40. }
Add Comment
Please, Sign In to add comment