You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implementing the Specification Pattern with Doctrine Repositories #17
changed the title [-]Implementing the Specification Patter with Doctrine Repositories[/-][+]Implementing the Specification Pattern with Doctrine Repositories[/+]on Jun 22, 2016
It wasn't so much the spec part, as much as I wanted a Specification that
can be turned in a query. That proved to be quite difficult and I ran out
of time.
Personally I prefer using a Query passing the data to a Handler. Then the Handler creates the Specifications to pass them to my repository. The Handler then returns the Set from the Collection.
A word on "coupling business logic with the specification pattern":
I can understand that looking at these concrete Doctrine implementations make you think, that business logic is linked to persistence. But coming from a DDD approach you would create a Base Specification like "filterGroup". Then you create a Doctrine (or Mysql, Mongo, InMemory) class based on that Spec and add only the stuff that will be related to the same Persistence storage: DoctrineUserRepository or InMemoryRepository.
What you want is the coupling of the Business Logic to the Specification. And then you build your infrastructure around it.
Where do you guys suggest to put the Specifications?
Normally I think they would go into the Domain / DomainModel namespace.
But since the examples are used with Doctrine the are coupled to the infrastructure.
At least they should go into Acme\Infrastructure.
Acme\Infrastructure\Persistence\Doctrine (where als the repositories live)
Activity
[-]Implementing the Specification Patter with Doctrine Repositories[/-][+]Implementing the Specification Pattern with Doctrine Repositories[/+]mbrevda commentedon Jun 22, 2016
My implementation is not implemented, that repo was to TRY to and implement the pattern... wasn't very successful.
webdevilopers commentedon Jun 22, 2016
Tried any of the others @mbrevda ? What was missing for success?
Nyholm commentedon Jun 22, 2016
The HappyDoctrineSpecification works. I've been using in in prod for over a year. I will soon tag version 1.0.
mbrevda commentedon Jun 22, 2016
It wasn't so much the spec part, as much as I wanted a Specification that
can be turned in a query. That proved to be quite difficult and I ran out
of time.
On Wed, Jun 22, 2016, 7:14 PM Tobias Nyholm notifications@github.com
wrote:
mablae commentedon Jun 23, 2016
@Nyholm Can you say something about your directory/namespacing schema for the custom specs?
webdevilopers commentedon Jun 26, 2016
Another Bundle I found is
RulerZby @K-Phoen:Using RulerZ, the two previous repositories can be refactored:
It is also possible to use the Specs for filtering directly inside Symfony Forms:
Personally I prefer using a Query passing the data to a Handler. Then the Handler creates the Specifications to pass them to my repository. The Handler then returns the Set from the Collection.
webdevilopers commentedon Jun 26, 2016
A word on "coupling business logic with the specification pattern":
http://www.whitewashing.de/2013/03/04/doctrine_repositories.html#comment-2751511485
I think @timglabisch also prefers this kind of approach?
http://www.whitewashing.de/2013/03/04/doctrine_repositories.html#comment-1280738273
Coming from this nice article by @beberlei:
http://www.whitewashing.de/2013/03/04/doctrine_repositories.html#comment-2751511485
Which was an inspiration on the @Happyr Doctrine-Specification btw..
webdevilopers commentedon Jun 26, 2016
There is also an bundle by @rikbruil inspired by @Happyr Doctrine-Specification implementing the Doctrine Paginator:
https://github.com/rikbruil/Doctrine-Specification
webdevilopers commentedon Jun 26, 2016
BTW: Doing my first steps with @Happyr now:
Works like a charm @Nyholm!
Testing some more complex stuff now:
Happyr/Doctrine-Specification#128
webdevilopers commentedon Jun 27, 2016
Where do you guys suggest to put the Specifications?
Normally I think they would go into the
Domain/DomainModelnamespace.But since the examples are used with Doctrine the are coupled to the infrastructure.
At least they should go into
Acme\Infrastructure.I've seen people adding a Domain namespace for this:
Thoughts?