Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove FilterProviderInterface #205

Open
wants to merge 3 commits into
base: 3.0.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Providing Filters via Modules

If you wish to indicate that your laminas-mvc module provides filters, have your `Module` class implement `Laminas\Filter\FilterProviderInterface`, which defines the method:
If you wish to indicate that your laminas-mvc module provides filters, have your `Module` class implement `Laminas\ModuleManager\Feature\FilterProviderInterface`, which defines the method:

```php
/**
Expand All @@ -11,6 +11,8 @@ public function getFilterConfig();

The method should return an array of configuration following the [laminas-servicemanager configuration format](https://docs.laminas.dev/laminas-servicemanager/configuring-the-service-manager/).

Further information can be found in the [Module Manager documentation](https://docs.laminas.dev/laminas-modulemanager/module-manager/#servicelistener).

If you are not using laminas-mvc, but are using a dependency injection container (e.g., if you are using Mezzio), you can also provide filters using the top-level `filters` configuration key; the value of that key should be laminas-servicemanager configuration, as linked above.

(laminas-mvc users may also provide configuration in the same way, and omit implementation of the `FilterProviderInterface`.)
5 changes: 5 additions & 0 deletions docs/book/v3/migration/v2-to-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,8 @@ Various filters such as `StringToLower` and `StringToUpper` inherited from the a
This class has been removed and the affected filters no longer inherit from anything.
In order to provide consistent handling of the `encoding` option that has been re-implemented in these filters, a new class `EncodingOption` has been introduced which provides static methods to validate a given encoding option.
This change is unlikely to affect you, unless you have inherited from this class. In which case, you will need to implement the provision of an encoding option for your custom filter and remove `AbstractUnicode` from your inheritance tree.

### Removal of the `FilterProviderInterface`

This legacy interface is related to Laminas MVC Module Manager integration and was superseded by `Laminas\ModuleManager\Feature\FilterProviderInterface`.
If your code still references `Laminas\Filter\FilterProviderInterface`, replace its usage with the interface [shipped by Module Manager](https://docs.laminas.dev/laminas-modulemanager/module-manager/#servicelistener).
11 changes: 0 additions & 11 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,6 @@
<code><![CDATA[strtolower]]></code>
</RedundantFunctionCall>
</file>
<file src="src/FilterProviderInterface.php">
<UnusedClass>
<code><![CDATA[FilterProviderInterface]]></code>
</UnusedClass>
</file>
<file src="src/HtmlEntities.php">
<DeprecatedClass>
<code><![CDATA[AbstractFilter]]></code>
Expand Down Expand Up @@ -337,12 +332,6 @@
</UnusedParam>
</file>
<file src="src/Module.php">
<PossiblyUnusedParam>
<code><![CDATA[$moduleManager]]></code>
</PossiblyUnusedParam>
<UndefinedDocblockClass>
<code><![CDATA[ModuleManager]]></code>
</UndefinedDocblockClass>
<UnusedClass>
<code><![CDATA[Module]]></code>
</UnusedClass>
Expand Down
23 changes: 0 additions & 23 deletions src/FilterProviderInterface.php

This file was deleted.

20 changes: 0 additions & 20 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Laminas\Filter;

use Laminas\ModuleManager\ModuleManager;
use Laminas\ServiceManager\ServiceManager;

/**
Expand All @@ -25,23 +24,4 @@ public function getConfig(): array
'service_manager' => $provider->getDependencyConfig(),
];
}

/**
* Register a specification for the FilterManager with the ServiceListener.
*
* @param ModuleManager $moduleManager
*/
public function init($moduleManager): void
{
$event = $moduleManager->getEvent();
$container = $event->getParam('ServiceManager');
$serviceListener = $container->get('ServiceListener');

$serviceListener->addServiceManager(
'FilterManager',
'filters',
FilterProviderInterface::class,
'getFilterConfig'
);
}
}
Loading