Download the PHP package webfactory/visibility-filter-bundle without Composer
On this page you can find all versions of the php package webfactory/visibility-filter-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download webfactory/visibility-filter-bundle
More information about webfactory/visibility-filter-bundle
Files in webfactory/visibility-filter-bundle
Package visibility-filter-bundle
Short Description Symfony Bundle that filters out invisible Doctrine entities in a centralised way
License MIT
Informations about the package visibility-filter-bundle
VisibilityFilterBundle – A centralised approach to visibility of Doctrine Entities
This bundle provides a Doctrine Filter which handles visibility filtering for Entities transparently for a whole application, removing the need to repeatedly phrase the filtering in every repository method of an Entity. Most notably, the filtering also applies to Doctrine queries that bypass the repository, like relationships declared in the entity mapping.
Getting started
First, you need to declare this bundle as a composer dependency.
Next, the bundle needs to be registered to Symfony. Depending on your Symfony version, this might look like that:
The filter class needs to be registered manually.
Important: The YAML key of the filter needs to visibility
, otherwise the filter won't be activated on requests.
Configuring the visibility column
This bundle assumes that the visibility determination is going to be based on a specific field in the Entity containing visibility information; e.g. functioning as a "visibility switch" containing "yes" or "no" or containing a visibility grade on a scale, based on which the visibility of the object will be determined.
Currently, only entities that have a visibility column configured will be filtered at all.
All you need to configure on your entity is which of its fields will be the one with the visibility information.
You can do that by Adding the VisibilityColumn()
annotation to that field.
Please note that configuring more than one field as visibility column will throw an exception.
Replacing the filter strategy
By default, the library makes you application only query entities from the database that have the string y
in their
visibility column. You can change this behaviour by overwriting the service
Webfactory\VisibilityFilterBundle\Filter\FilterStrategy
with your own implementation.
Your implementation needs to implement the FilterStrategy
interface. If you only want to change the y
string to
something different, you can use the Webfactory\VisibilityFilterBundle\Filter\Strategy\ValueInField
implementation
and provide it with a different visibleValue
in its constructor.
All versions of visibility-filter-bundle with dependencies
doctrine/annotations Version ^1.12
doctrine/doctrine-bundle Version ^1.12.13|^2.0
doctrine/orm Version ^2.7.2
symfony/config Version ^5.4|^6.4
symfony/dependency-injection Version ^5.4|^6.4
symfony/event-dispatcher Version ^5.4|^6.4
symfony/http-kernel Version ^5.4|^6.4