Skip to content

Commit

Permalink
Merge pull request #4 from jeyroik/v0
Browse files Browse the repository at this point in the history
added json rpc request/response support for the stage before.index.re…
  • Loading branch information
jeyroik committed Dec 1, 2020
2 parents 45ffb77 + 60937b1 commit c3c1f00
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.2.1

- Стадия `extas.json.rpc.before.index.response` (и её именованная версия) теперь наследуют `IHasJsonRpcRequest` и `IhasJsonRpcResponse`.

# 0.2.0

- Появилась стадия `extas.json.rpc.before.index.response`, которая позволяет получить доступ к элементам до помещения их в результат.
Expand Down
4 changes: 2 additions & 2 deletions src/components/operations/jsonrpc/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ public function run(): array
protected function runStageBeforeIndexResponse(array $items): array
{
$stage = IStageJsonRpcBeforeIndexResponse::NAME;
foreach ($this->getPluginsByStage($stage) as $plugin) {
foreach ($this->getPluginsByStage($stage, $this->getHttpIO()) as $plugin) {
/**
* @var IStageJsonRpcBeforeIndexResponse $plugin
*/
$items = $plugin($items);
}

$stage .= '.' . $this->getOperation()->getName();
foreach ($this->getPluginsByStage($stage) as $plugin) {
foreach ($this->getPluginsByStage($stage, $this->getHttpIO()) as $plugin) {
/**
* @var IStageJsonRpcBeforeIndexResponse $plugin
*/
Expand Down
4 changes: 3 additions & 1 deletion src/interfaces/stages/IStageJsonRpcBeforeIndexResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
namespace extas\interfaces\stages;

use extas\interfaces\IItem;
use extas\interfaces\http\IHasJsonRpcRequest;
use extas\interfaces\http\IHasJsonRpcResponse;

/**
* Interface IStageJsonRpcAfterIndex
*
* @package extas\interfaces\stages
* @author jeyroik <jeyroik@gmail.com>
*/
interface IStageJsonRpcBeforeIndexResponse
interface IStageJsonRpcBeforeIndexResponse extends IHasJsonRpcRequest, IHasJsonRpcResponse
{
public const NAME = 'extas.json.rpc.before.index.response';

Expand Down
5 changes: 5 additions & 0 deletions tests/jsonrpc/misc/BeforeIndexResponse.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace tests\jsonrpc\misc;

use extas\components\http\THasJsonRpcRequest;
use extas\components\http\THasJsonRpcResponse;
use extas\components\plugins\Plugin;
use extas\interfaces\IItem;
use extas\interfaces\stages\IStageJsonRpcBeforeIndexResponse;
Expand All @@ -13,6 +15,9 @@
*/
class BeforeIndexResponse extends Plugin implements IStageJsonRpcBeforeIndexResponse
{
use THasJsonRpcResponse;
use THasJsonRpcRequest;

/**
* @param IItem[] $items
* @return array
Expand Down
5 changes: 5 additions & 0 deletions tests/jsonrpc/misc/BeforeIndexResponseCustom.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace tests\jsonrpc\misc;

use extas\components\http\THasJsonRpcRequest;
use extas\components\http\THasJsonRpcResponse;
use extas\components\plugins\Plugin;
use extas\interfaces\IItem;
use extas\interfaces\stages\IStageJsonRpcBeforeIndexResponse;
Expand All @@ -13,6 +15,9 @@
*/
class BeforeIndexResponseCustom extends Plugin implements IStageJsonRpcBeforeIndexResponse
{
use THasJsonRpcResponse;
use THasJsonRpcRequest;

/**
* @param IItem[] $items
* @return array
Expand Down

0 comments on commit c3c1f00

Please sign in to comment.