# |
Jul 20th 2017, 16:25 |
inoas |
yes avoiding duplicate code is good also the validator already got unit tests |
# |
Jul 20th 2017, 16:22 |
jeremyharris |
I may fork and play with it at some point, don’t have time right now though. maybe next week |
# |
Jul 20th 2017, 16:22 |
jeremyharris |
one of the big reasons to use it would be to avoid a bunch of duplicate code |
# |
Jul 20th 2017, 16:21 |
jeremyharris |
remember, it just validates arrays, which is all these options are |
# |
Jul 20th 2017, 16:21 |
jeremyharris |
I think some of those problems could be solved with the existing validator - it can do coexistence as well as nested |
# |
Jul 20th 2017, 16:21 |
jeremyharris |
:slightly_smiling_face: |
# |
Jul 20th 2017, 16:20 |
inoas |
but it was a nice exertice into spl autoload, interfaces, builders, factories for me :) |
# |
Jul 20th 2017, 16:20 |
inoas |
I have answered here https://gist.github.com/inoas/5d71c67f1714fc941a3e93bb408d1b7a |
# |
Jul 20th 2017, 16:15 |
inoas |
right now it has some ugly hacks inside (VoidReturnType but also validationErrors passed as a reference) |
# |
Jul 20th 2017, 16:14 |
inoas |
and it is very little code to declare the schema and to use the builder |
# |
Jul 20th 2017, 16:13 |
inoas |
and auto completion on the opt() methods IF you declare the functions (else it uses __get()) |
# |
Jul 20th 2017, 16:13 |
inoas |
schema |
# |
Jul 20th 2017, 16:13 |
inoas |
this style allows auto completion by IDEs for types in the schmea |
# |
Jul 20th 2017, 16:13 |
inoas |
I am not sure what would happen to nesting |
# |
Jul 20th 2017, 16:13 |
jeremyharris |
but yeah, I think this style is a good compromise |
# |
Jul 20th 2017, 16:12 |
jeremyharris |
I think just extending the validator and comparing $this->_fields (which are all defined validator fields aka option keys) to the keys in the data might work |
# |
Jul 20th 2017, 16:12 |
inoas |
well "works" as in you can see things ;) |
# |
Jul 20th 2017, 16:12 |
inoas |
if you pull that and just run OptionsBuilderTest.php in some browser/console it already works |
# |
Jul 20th 2017, 16:12 |
inoas |
but yes I read that and to look in the console io |
# |
Jul 20th 2017, 16:11 |
inoas |
Sadly it blows my head right now... already |
# |
Jul 20th 2017, 16:10 |
jeremyharris |
I like the concept so far. Did you take a look at my comment about re-using the validator class? |
# |
Jul 20th 2017, 16:10 |
inoas |
the schema validator is only started... string and int type |
# |
Jul 20th 2017, 16:10 |
inoas |
but you don't have to |
# |
Jul 20th 2017, 16:10 |
inoas |
you can add all the methods to be setters for the options builder |
# |
Jul 20th 2017, 16:09 |
inoas |
jeremy well here is at least some idea/concept https://github.com/inoas/options/blob/master/OptionBuilderTest.php |
# |
Jul 20th 2017, 15:54 |
admad |
Separate flash message pages were the stupidest thing |
# |
Jul 20th 2017, 15:40 |
shuyi |
magic is one of the bad things about PHP ... which I think is why nice things like Visual Studio don't come to us ... |
# |
Jul 20th 2017, 15:38 |
shuyi |
and doing grandfather coding styles |
# |
Jul 20th 2017, 15:38 |
jeremyharris |
remnants from rails inspiration I think |
# |
Jul 20th 2017, 15:38 |
shuyi |
I inherited this code from someone who loved doing copy and paste ... |
# |
Jul 20th 2017, 15:38 |
inoas |
magic! |
# |
Jul 20th 2017, 15:38 |
dereuromark |
yeah, totally uncool |
# |
Jul 20th 2017, 15:38 |
jeremyharris |
way back in the day :slightly_smiling_face: would redirect to an actual view if I recall |
# |
Jul 20th 2017, 15:38 |
inoas |
there was controller::flash() oO ;)( |
# |
Jul 20th 2017, 15:37 |
inoas |
shyui it removed $this->Session->setFlash ages ago |
# |
Jul 20th 2017, 15:36 |
shuyi |
@dereuromark you are my hero ... the upgrade tool from cake themselves, does not even as well as yours |
# |
Jul 20th 2017, 15:36 |
dereuromark |
You can also use https://github.com/dereuromark/cakephp-flash and have even more awesome flash messaging support :slightly_smiling_face: |
# |
Jul 20th 2017, 15:35 |
dereuromark |
use the component (Flash) - $this->Flash->success() as we all do |
# |
Jul 20th 2017, 15:35 |
dereuromark |
oh yeah that one was an anti pattern |
# |
Jul 20th 2017, 15:35 |
shuyi |
```Controller::flash() has been removed. This method was rarely used in real applications and served no purpose anymore.``` |
# |
Jul 20th 2017, 15:35 |
dereuromark |
It was long time ago removed from Session into its own Component, maybe you confused a few things here |