-
-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[5.x] Add hook to query on entries listing (#10479)
Co-authored-by: duncanmcclean <[email protected]> Co-authored-by: Jason Varga <[email protected]>
- Loading branch information
1 parent
ed1d8f4
commit a96a6a1
Showing
4 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Statamic\Hooks\CP; | ||
|
||
use Statamic\Support\Traits\Hookable; | ||
|
||
class EntriesIndexQuery | ||
{ | ||
use Hookable; | ||
|
||
public function __construct(private $query, private $collection) | ||
{ | ||
// | ||
} | ||
|
||
public function paginate(?int $perPage) | ||
{ | ||
$payload = $this->runHooksWith('query', [ | ||
'query' => $this->query, | ||
'collection' => $this->collection, | ||
]); | ||
|
||
return $payload->query->paginate($perPage); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Statamic\Hooks; | ||
|
||
class Payload | ||
{ | ||
public function __construct(private array $payload) | ||
{ | ||
// | ||
} | ||
|
||
public function __get($key) | ||
{ | ||
return $this->payload[$key] ?? null; | ||
} | ||
|
||
public function __set($key, $value) | ||
{ | ||
$this->payload[$key] = $value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters