Download the PHP package jurjean/spray-persistence-bundle without Composer
On this page you can find all versions of the php package jurjean/spray-persistence-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package spray-persistence-bundle
Spray\PersistenceBundle
A Symfony2 bundle that enhances Doctrine2 repository functionality.
Introduction
This bundle provides a way to query your objects in an abstract manner:
It has a common API:
Allows easy pagination:
And can be used standalone as well! You don't need symfony, you can integrate it in any framework of choice (however Doctrine is a requirement).
Installation
Require "jurjean/spray-persistence-bundle" in your composer.json:
Register SprayPersistenceBundle in your AppKernel:
The problem
Doctrine2 provides a nice API that lets you query for entities through a repository. However the repository pattern is not very DRY.
If you want to do queries like described above, you could end up with a repository like so:
As you can imagine, the only way to add more conditions is by duplication. That's where the RepositoryFilter comes in.
Entity filters
Prioritized entity filters
You may want a filter to be prioritized. To do so you must implement the PrioritizedFilterInterface:
No matter in which order you add these filters, the order of execution still would be first and then last.
Conflicting entity filters
If you have filters that may conflict with each other (for instance if they add a where statement on the same column) you can implement the ConflictingFilterInterface:
If 'another' exists in the repository filter scope, it will be removed if ArticlesConflictingWith is added.
Filter registry
The filter registry is used to provide repository filters with available entity filters. You can either build them up programmatically, or create registry classes yourself. After that you need to inject the registry into the repository filter.
Symfony integration
You can configure your repository filters easily by extending the parent di container definition _spray_persistence.repositoryfilter, and providing it with an Entity name as argument.
Filters are added by tagging them with name _spray_persistence.entityfilter. You can either set them up globally (for all repositories) or locally (for one repository). You make them local by adding repository as a tag option.
Examples
For more examples please have a look at the integration tests for this project.
All versions of spray-persistence-bundle with dependencies
doctrine/doctrine-bundle Version 1.*
symfony/dependency-injection Version 2.*
symfony/http-kernel Version 2.*