This commit is contained in:
R. Eric Wheeler 2016-07-11 14:58:53 -07:00
parent 15627da05c
commit a00d9b49a0
1 changed files with 45 additions and 47 deletions

View File

@ -16,26 +16,26 @@ use Pimple\Container;
use Pimple\ServiceProviderInterface; use Pimple\ServiceProviderInterface;
use Silex\Api\BootableProviderInterface; use Silex\Api\BootableProviderInterface;
use Silex\Application; use Silex\Application;
use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraints\{
use Symfony\Component\Validator\Constraints\Email; Collection,
use Symfony\Component\Validator\Constraints\Length; Email,
use Symfony\Component\Validator\Constraints\NotBlank; Length,
use Symfony\Component\Validator\Constraints\NotNull; NotBlank,
use Symfony\Component\Validator\Constraints\Regex; NotNull,
Regex
};
/** /**
* Class ConfigServiceProvider * Class ConfigServiceProvider
* *
* @package Sikofitt\Config * @package Sikofitt\Config
*/ */
class ConfigServiceProvider implements ServiceProviderInterface, BootableProviderInterface class ConfigServiceProvider implements ServiceProviderInterface, BootableProviderInterface {
{
/** /**
* @param Container $app * @param Container $app
*/ */
public function register(Container $app) public function register(Container $app) {
{
$app['config'] = function ($app) { $app['config'] = function ($app) {
$config = Config::load($app['config.path']); $config = Config::load($app['config.path']);
@ -43,15 +43,13 @@ class ConfigServiceProvider implements ServiceProviderInterface, BootableProvide
}; };
} }
public function boot(Application $app) public function boot(Application $app) {
{
$configItems = [ $configItems = [
'email' => $app->config('app.email'), 'email' => $app->config('app.email'),
'phone' => $app->config('app.phone'), 'phone' => $app->config('app.phone'),
]; ];
$constraints = [ $constraints = [
'email' => [ 'email' => [
new NotNull(['message' => 'Email value in app config is not present.']), new NotNull(['message' => 'Email value in app config is not present.']),