add ability to pass operator via context #27
Comments
What is the advantage compared to using the asserter? |
for my preticular usage im trying to use this along with this jquery library http://mistic100.github.io/jQuery-QueryBuilder/ to build rules in a gui so the operator changes regularly for each rule. |
I think we have to define a pre-processor in this case. /cc @hoaproject/hoackers Maybe this is a little bit overkill? |
I specifically ping @stephpy on this issue since he has started a similar project (the GUI). |
Hi, In this example (of Jquery QueryBuilder), you'll have to define many operators in context, so if i follow you, you'll have to do:
Then, you'll have to edit yours rules to transform to This is not readable, and hard do debug ... BTW, I don't see any benefit to inject operator in Context rather than trasforming |
no, im saving the rules once the user is done into json and then decoding that with php resulting in an object of each rule so i only need one operator, i guess i could do a strreplace on the rule text and replace the word operator with the string version from the rule, |
@stephpy You are right, this is why I have proposed a pre-processor. Thoughts? |
I guess this is a specific case and we should not introduce this kind of things on Hoa\Ruler. You could add as you say a |
Thanks for the help though guys. |
You're welcome. |
@th3fallen Did we answer to your question? |
@Hywan Somewhat i believe i can just do the the str_replace and get my desired result. |
@th3fallen Another possibility is to add a “callback” function, something like: |
@Hywan Actually i found it to be easier just to add the operators in the style i needed them using the setOperator method. Works like a charm. |
@th3fallen Perfect then :-). Can I ask you to ping us when your project will be finalized? This is a nice usecase! |
@Hywan Will do, a question for you though, what version of php is this library ment to be used with. Im noticing that hoa/compiler/Hoa/Compiler/Llk/Parser.php:234 the exception there is not being fired and is showing an error in my ide of "The thrown object must be an instance of the Exception" |
It's because |
@Metalaka When running the application i still get no thrown errors, i actually get no output at all.... |
@th3fallen Can you open on |
How far did you come with this use-case? I'm wanting to implement the same kind of functionality |
@janvandijk see #27 (comment) i did it using the |
Awesome, I did read that comment... was wondering if there were any changes since then. (Thank you for your reply!) 👍 |
It would be fantastic if i could pass the operator in via the context like the following example
The text was updated successfully, but these errors were encountered: