Filter Factories

Filter injection is performed through a Factory class, just like handlers. If you want to send a class to your filter class, you must define a Factory class for each filter class as follows.

src/App/Filter/Companies/SaveFilterFactory.php

<?php
declare(strict_types=1);

namespace App\Filter\Companies;

use Psr\Container\ContainerInterface;
use Laminas\Db\Adapter\AdapterInterface;
use Laminas\ServiceManager\Factory\FactoryInterface;

class SaveFilterFactory implements FactoryInterface
{
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
    {
        return new SaveFilter($container->get(AdapterInterface::class));
    }
}