forked from hyva-themes/magento2-hyva-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHyvaGridSourceProcessorInterface.php
52 lines (48 loc) · 1.83 KB
/
HyvaGridSourceProcessorInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php declare(strict_types=1);
namespace Hyva\Admin\Api;
use Magento\Framework\Api\SearchCriteriaInterface;
/**
* Implement this interface in your module and configure it on a grid:
*
* <grid>
* <source>
* ... other source config ...
* <processors>
* <processor class="\YOur\Module\HyvaGridProcessor\MyGridQueryProcessor"/>
* </processors>
* </source>
* </grid>
*/
interface HyvaGridSourceProcessorInterface
{
/**
* Provides the ability to mutate the grid $source before the grid data is loaded.
*
* The search criteria will already have been applied (if applicable for a given source type).
* Do not mutate $searchCriteria since that will cause multiple loads (it's signature changes,
* see \Hyva\Admin\Model\GridSource\SearchCriteriaIdentity).
*
* The type of $source is grid configuration dependent (it might be a Select instance, or a
* collection, or a repository, ...).
*
* @param mixed $source
* @param SearchCriteriaInterface $searchCriteria
* @param string $gridName
*/
public function beforeLoad($source, SearchCriteriaInterface $searchCriteria, string $gridName): void;
/**
* Provides the ability to change the raw grid result after it is loaded.
*
* The method must return the new result or null. The $result type depends on the grid configuration.
* If null is returned, the result value from before afterLoad is used.
*
* Do not mutate $searchCriteria since that will cause multiple loads (because its signature changes,
* see note on beforeLoad above).
*
* @param mixed $rawResult
* @param SearchCriteriaInterface $searchCriteria
* @param string $gridName
* @return mixed
*/
public function afterLoad($rawResult, SearchCriteriaInterface $searchCriteria, string $gridName);
}