本文整理汇总了PHP中Illuminate\Validation\Factory::resolver方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::resolver方法的具体用法?PHP Factory::resolver怎么用?PHP Factory::resolver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Validation\Factory
的用法示例。
在下文中一共展示了Factory::resolver方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->mergeConfigFrom(__DIR__ . '/../config/captcha.php', 'mews.captcha');
/**
* @param $app
* @return Captcha
*/
$this->app->bind('captcha', function ($app) {
return new Captcha($app['Illuminate\\Filesystem\\Filesystem'], $app['Illuminate\\Config\\Repository'], $app['Intervention\\Image\\ImageManager'], $app['Illuminate\\Session\\Store'], $app['Illuminate\\Hashing\\BcryptHasher'], $app['Illuminate\\Support\\Str']);
});
/**
* @param Captcha $captcha
* @param $config
* @return \Intervention\Image\ImageManager
*/
$this->app['router']->get('captcha/{config?}', 'Chekun\\Captcha\\CaptchaController@draw');
$this->app['validator'] = $this->app->share(function ($app) {
$validator = new Factory($app['translator']);
$validator->setPresenceVerifier($this->app['validation.presence']);
$validator->resolver(function ($translator, $data, $rules, $messages) {
return new CaptchaValidator($translator, $data, $rules, $messages);
});
return $validator;
});
}
示例2: testCustomResolverIsCalled
public function testCustomResolverIsCalled()
{
unset($_SERVER['__validator.factory']);
$translator = m::mock('Symfony\\Component\\Translation\\TranslatorInterface');
$factory = new Factory($translator);
$factory->resolver(function ($translator, $data, $rules) {
$_SERVER['__validator.factory'] = true;
return new Illuminate\Validation\Validator($translator, $data, $rules);
});
$validator = $factory->make(array('foo' => 'bar'), array('baz' => 'boom'));
$this->assertTrue($_SERVER['__validator.factory']);
$this->assertEquals($translator, $validator->getTranslator());
$this->assertEquals(array('foo' => 'bar'), $validator->getData());
$this->assertEquals(array('baz' => array('boom')), $validator->getRules());
unset($_SERVER['__validator.factory']);
}
示例3: register
public function register()
{
$this->app->singleton('validation.presence', function ($app) {
return new DatabasePresenceVerifier($app['db']);
});
$this->app->singleton('validator', function ($app) {
$validator = new Factory($app['translator'], $app);
$validator->resolver(function ($translator, $data, $rules, $messages, $customAttributes) {
return new \App\Http\Services\Validator($translator, $data, $rules, $messages, $customAttributes);
});
// The validation presence verifier is responsible for determining the existence
// of values in a given data collection, typically a relational database or
// other persistent data stores. And it is used to check for uniqueness.
if (isset($app['validation.presence'])) {
$validator->setPresenceVerifier($app['validation.presence']);
}
return $validator;
});
}
示例4: resolver
/**
* Set the Validator instance resolver.
*
* @param \Closure $resolver
* @return void
* @static
*/
public static function resolver($resolver)
{
\Illuminate\Validation\Factory::resolver($resolver);
}
示例5: resolver
/**
* Set the Validator instance resolver.
*
* @param \Closure $resolver
* @return void
*/
public function resolver(Closure $resolver)
{
$this->factory->resolver($resolver);
}
示例6: getValidationFactory
/**
* @return \Illuminate\Validation\Factory
*/
public function getValidationFactory()
{
if (isset($this->app['validator'])) {
return $this->app['validator'];
}
$factory = new Factory(new IdentityTranslator(), $this->app);
if ($this->override !== null) {
$factory->resolver($this->override);
}
return $factory;
}