Skip to content

Commit

Permalink
Merge pull request #205 from gsteel/v3/remove-filter-provider-interface
Browse files Browse the repository at this point in the history
Remove `FilterProviderInterface`
  • Loading branch information
gsteel authored Jan 6, 2025
2 parents 71e42cc + a5fd879 commit e61592b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 55 deletions.
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 @@ -343,3 +343,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 @@ -185,11 +185,6 @@
<code><![CDATA[(bool) $flag]]></code>
</RedundantCastGivenDocblockType>
</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 @@ -309,12 +304,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'
);
}
}

0 comments on commit e61592b

Please sign in to comment.