New in Mouf 2: improved validators
Mouf has had self-check validators for quite a long time now. And for quite a long time, it was possible to extend those validators in your packages.
It was possible, but not complely easy, as you add to write several conf files to set them up.
This time is over! Now, you can write your own validators in a breeze, just by extending one interface.
Here is a sample:
class SplashHtaccessValidator implements MoufStaticValidatorInterface { /** * Runs the validation of the class. * Returns a MoufValidatorResult explaining the result. * * @return MoufValidatorResult */ public static function validateClass() { if (file_exists(ROOT_PATH.".htaccess")) { return new MoufValidatorResult(MoufValidatorResult::WARN, "Unable to find .htaccess file."); } else { return new MoufValidatorResult(MoufValidatorResult::SUCCESS, ".htaccess file found."); } } }
A simple method that returns a "MoufValidatorResult", and each time you start Mouf, your validator will be executed. There are 2 kinds of validators: "class" validators (one validation per class) and "instance" validators (one validation per instance defined in Mouf)
And as a bonus, the Mouf self-check status screen has been revamped:
Tags :
- admin's blog
- Log in to post comments
What’s new on Mouf :
- TDBM 5.0 is released 09/11/2017
- Quickstarting a Mouf appl... 15/06/2017
- Building beautiful datagr... 05/10/2016
- Official release of TDBM... 14/06/2016
- Announcing Mouf 2.1 first... 01/03/2016
- Mouf + Magento + PSR-7 =... 30/06/2015
- Standardizing the way we... 10/06/2015
- Container interoperabilit... 09/06/2015
- Container-interop + PSR7... 01/06/2015
- New in Mouf: a console! 19/05/2015