Skip to content

Commit

Permalink
Merge commit b3d9511b716c7b8631b59796b83c60767596a6ba into new-master
Browse files Browse the repository at this point in the history
  • Loading branch information
spiralbot committed May 15, 2024
1 parent f9727dc commit 537643a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 27 deletions.
5 changes: 0 additions & 5 deletions src/Config/FiltersConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

namespace Spiral\Filters\Config;

use Spiral\Core\CoreInterceptorInterface;
use Spiral\Core\InjectableConfig;
use Spiral\Interceptors\InterceptorInterface;

final class FiltersConfig extends InjectableConfig
{
Expand All @@ -16,9 +14,6 @@ final class FiltersConfig extends InjectableConfig
'interceptors' => [],
];

/**
* @return array<class-string<CoreInterceptorInterface|InterceptorInterface>>
*/
public function getInterceptors(): array
{
return (array)($this->config['interceptors'] ?? []);
Expand Down
14 changes: 3 additions & 11 deletions src/Model/FilterProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
use Spiral\Filters\Model\Schema\Builder;
use Spiral\Filters\Model\Schema\InputMapper;
use Spiral\Filters\InputInterface;
use Spiral\Interceptors\Context\CallContext;
use Spiral\Interceptors\Context\Target;
use Spiral\Interceptors\HandlerInterface;
use Spiral\Models\SchematicEntity;

/**
Expand All @@ -22,13 +19,11 @@
*/
final class FilterProvider implements FilterProviderInterface
{
private readonly bool $isLegacy;
public function __construct(
private readonly ContainerInterface $container,
private readonly ResolverInterface $resolver,
private readonly HandlerInterface|CoreInterface $core
private readonly CoreInterface $core
) {
$this->isLegacy = !$core instanceof HandlerInterface;
}

public function createFilter(string $name, InputInterface $input): FilterInterface
Expand Down Expand Up @@ -61,12 +56,9 @@ public function createFilter(string $name, InputInterface $input): FilterInterfa
$errors = \array_merge($errors, $inputErrors);

$entity = new SchematicEntity($data, $schema);
$args = [
return $this->core->callAction($name, 'handle', [
'filterBag' => new FilterBag($filter, $entity, $schema, $errors),
];
return $this->isLegacy
? $this->core->callAction($name, 'handle', $args)
: $this->core->handle(new CallContext(Target::fromPair($name, 'handle'), $args));
]);
}

private function createFilterInstance(string $name): FilterInterface
Expand Down
12 changes: 1 addition & 11 deletions src/Model/Interceptor/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
use Spiral\Core\CoreInterface;
use Spiral\Filters\Model\FilterBag;
use Spiral\Filters\Model\FilterInterface;
use Spiral\Interceptors\Context\CallContext;
use Spiral\Interceptors\HandlerInterface;

/**
* @psalm-type TParameters = array{filterBag: FilterBag}
*/
final class Core implements CoreInterface, HandlerInterface
final class Core implements CoreInterface
{
/**
* @param-assert TParameters $parameters
Expand All @@ -24,12 +22,4 @@ public function callAction(string $controller, string $action, array $parameters

return $parameters['filterBag']->filter;
}

public function handle(CallContext $context): FilterInterface
{
$args = $context->getArguments();
\assert($args['filterBag'] instanceof FilterBag);

return $args['filterBag']->filter;
}
}

0 comments on commit 537643a

Please sign in to comment.