M
M
Michael2018-02-07 19:48:47
PHP
Michael, 2018-02-07 19:48:47

How to start using the specification template?

I have repositories in which I get data from api and database. Outside I manipulate only entities (models). There was a need for a universal specification of sampling rules. Simply put, I need to specify conditions for the findBy($criteria) method, which inside, depending on the type of resource, will be converted into a condition format that the resource understands.
I kind of found what I need: https://github.com/K-Phoen/rulerz I thought that I could write a condition converter into an understandable format of internal resources. But there is an abstraction in an abstraction based on an abstraction and so far I can’t figure out how to start using it correctly and whether this lib is suitable for my tasks.
Is it possible to implement the task using it? Wouldn't it be very difficult to implement a converter for resources?
It uses hoaproject / Ruler inside it, maybe it should be used?
Share your experience with her...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AlexHell, 2018-02-14
@AlexHell

I will give an answer to a more general question according to the "template <specification>" - this is just a class with a method that encapsulates knowledge about something, often the creation or operation algorithm, with the details of the arguments (which can be many and they are not mandatory)
specifically for sql it can be a sql query string construct to the database according to the passed criteria, and without several abstractions for the case with sql it will not work. criteria is much
more specific on your question is not clear here is
"In other words, I need to specify conditions for the findBy($criteria) method, which inside, depending on the type of resource, will be converted into a condition format that the resource understands."
what is "depending on the type of resource" - what types of resources?
in general, you should have a filling of "real work", for the specification case: when specific methods are called in your findBy that are in the specification, you may need to group them with other templates / entities, for example, from the specification, call a specific method of one of the polymorphic converters (IImplementer, Implementer1, Implementer2) or a polymorphic builder, for example, in the Invoke(IImplementer) method of your specification, the IImplementer methods will twitch, which for the case with API will prepare one line via http and for the case with sql database they will generate a sql string, append it to the result or similar

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question