Skip to content

Commit

Permalink
Fixing the ValidatorServiceProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanedev-maroc committed May 19, 2017
1 parent 7328ed3 commit c4af573
Showing 1 changed file with 24 additions and 37 deletions.
61 changes: 24 additions & 37 deletions src/Providers/ValidatorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use Arcanedev\Support\ServiceProvider;
use Closure;
use Illuminate\Contracts\Foundation\Application;

/**
* Class ValidatorServiceProvider
Expand All @@ -13,54 +12,31 @@
class ValidatorServiceProvider extends ServiceProvider
{
/* -----------------------------------------------------------------
| Properties
| Main Methods
| -----------------------------------------------------------------
*/
/**
* The Validator instance.
*
* @var \Illuminate\Validation\Factory
*/
protected $validator;

/* -----------------------------------------------------------------
| Constructor
| -----------------------------------------------------------------
*/
/**
* {@inheritdoc}
* Register the service provider.
*/
public function __construct(Application $app)
public function register()
{
parent::__construct($app);

$this->validator = $app['validator'];
//
}

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* {@inheritdoc}
* Boot the service provider.
*/
public function boot()
{
$this->registerUserValidators();
}

/**
* {@inheritdoc}
*/
public function register()
{
//
}

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Validators
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/

/**
* Register the user validators.
*/
Expand All @@ -77,10 +53,21 @@ function($message, $attribute) {
);
}

/* ------------------------------------------------------------------------------------------------
| Other Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Other Methods
| -----------------------------------------------------------------
*/

/**
* Get the validator instance.
*
* @return \Illuminate\Validation\Factory
*/
private function validator()
{
return $this->app['validator'];
}

/**
* Extend validator.
*
Expand All @@ -90,9 +77,9 @@ function($message, $attribute) {
*/
private function extendValidator($name, $class, Closure $replacer = null)
{
$this->validator->extend($name, "{$class}@validate" . studly_case($name));
$this->validator()->extend($name, "{$class}@validate" . studly_case($name));

if ( ! is_null($replacer))
$this->validator->replacer($name, $replacer);
$this->validator()->replacer($name, $replacer);
}
}

0 comments on commit c4af573

Please sign in to comment.