当前位置: 首页>>代码示例>>PHP>>正文


PHP Factory::setPresenceVerifier方法代码示例

本文整理汇总了PHP中Illuminate\Validation\Factory::setPresenceVerifier方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::setPresenceVerifier方法的具体用法?PHP Factory::setPresenceVerifier怎么用?PHP Factory::setPresenceVerifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Validation\Factory的用法示例。


在下文中一共展示了Factory::setPresenceVerifier方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setValidator

 protected function setValidator()
 {
     $filesystem = new FileLoader(new Filesystem(), CONFIG_DIR . DIRECTORY_SEPARATOR . 'langs');
     $translator = new Translator($filesystem, Main::$app->web->get('locale', false) ?: 'en');
     $this->validator = new ValidatorFactory($translator);
     $verifier = new DatabasePresenceVerifier($this->capsule->getDatabaseManager());
     $this->validator->setPresenceVerifier($verifier);
 }
开发者ID:xandros15,项目名称:aigisu,代码行数:8,代码来源:Connection.php

示例2: 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;
     });
 }
开发者ID:chekun,项目名称:captcha,代码行数:30,代码来源:CaptchaServiceProvider.php

示例3: register

 public function register(Application $app)
 {
     $core = $app;
     $app['illuminate'] = new Container();
     $app['illuminate']['config'] = array('cache.driver' => 'memcached', 'cache.memcached' => array(array('host' => 'localhost', 'port' => '11211')));
     $app['illuminate']->bindShared('validator', function ($app) use($core) {
         $validator = new Factory($core['translator'], $app);
         // 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;
     });
     $app['illuminate']->bindShared('cache', function ($app) {
         return new CacheManager($app);
     });
     $app['illuminate']->bindShared('cache.store', function ($app) {
         return $app['cache']->driver();
     });
     $app['illuminate']->bindShared('memcached.connector', function () {
         return new MemcachedConnector();
     });
 }
开发者ID:vespakoen,项目名称:bolt-core,代码行数:25,代码来源:IlluminateServiceProvider.php

示例4: registerValidationFactory

 /**
  * @return void
  */
 protected function registerValidationFactory()
 {
     $this->app->singleton('validator', function ($app) {
         $validator = new Factory($app['translator'], $app);
         if (isset($app['validation.presence'])) {
             $validator->setPresenceVerifier($app['validation.presence']);
         }
         return $validator;
     });
 }
开发者ID:darrengopower,项目名称:framework,代码行数:13,代码来源:ValidationServiceProvider.php

示例5: registerValidationFactory

 /**
  * Register the validation factory.
  *
  * @return void
  */
 protected function registerValidationFactory()
 {
     $validator = new Factory($this->container['translator'], $this->container);
     // 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($this->container['validation.presence'])) {
         $validator->setPresenceVerifier($this->container['validation.presence']);
     }
     return $validator;
 }
开发者ID:txthinking,项目名称:validation,代码行数:16,代码来源:ValidatorProvider.php

示例6: register

 /**
  * Register any validation services.
  *
  * @param  \Pimple\Container $container
  */
 public function register(Container $container)
 {
     $this->registerPresenceVerifier($container);
     $container['validator'] = function () use($container) {
         $validator = new Factory($container['translator']);
         if (isset($container['validation.presence'])) {
             $validator->setPresenceVerifier($container['validation.presence']);
         }
         return $validator;
     };
 }
开发者ID:bvqbao,项目名称:app-skeleton,代码行数:16,代码来源:ValidationServiceProvider.php

示例7: __construct

 /**
  * Create a new Validator factory instance.
  *
  * @param  \Illuminate\Database\Capsule\Manager $db
  * @return \Illuminate\Validation\Factory
  */
 public function __construct($db)
 {
     if (!$this->factory) {
         /**
          * illuminate/translation (Translator) package need for correct work of Validator
          */
         $translator = new Translator('en');
         $this->factory = new Factory($translator);
         /**
          * To set database presence verifier we need database connection instance,
          * which is implements ConnectionResolverInterface. For this purpose 
          * Illuminate\Database\Capsule\Manager class, which we get from $db arg,
          * have getDatabaseManager() function.
          * With defined DatabasePresenceVerifier we can use rules such as: 
          *      unique:table,column,except,idColumn
          *      exists:table,column
          */
         $dbManager = $db->getDatabaseManager();
         $this->factory->setPresenceVerifier(new DatabasePresenceVerifier($dbManager));
     }
     return $this->factory;
 }
开发者ID:mrcoco,项目名称:tinyshop-v2,代码行数:28,代码来源:validator.php

示例8: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->registerPresenceVerifier();
     $this->app['validator'] = $this->app->share(function ($app) {
         $validator = new Factory($app['translator'], $app);
         // 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;
     });
 }
开发者ID:lenninsanchez,项目名称:donadores,代码行数:19,代码来源:ValidationServiceProvider.php

示例9: testMakeMethodCreatesValidValidator

 public function testMakeMethodCreatesValidValidator()
 {
     $translator = m::mock('Symfony\\Component\\Translation\\TranslatorInterface');
     $factory = new Factory($translator);
     $validator = $factory->make(array('foo' => 'bar'), array('baz' => 'boom'));
     $this->assertEquals($translator, $validator->getTranslator());
     $this->assertEquals(array('foo' => 'bar'), $validator->getData());
     $this->assertEquals(array('baz' => array('boom')), $validator->getRules());
     $presence = m::mock('Illuminate\\Validation\\PresenceVerifierInterface');
     $factory->extend('foo', function () {
     });
     $factory->setPresenceVerifier($presence);
     $validator = $factory->make(array(), array());
     $this->assertEquals(array('foo' => function () {
     }), $validator->getExtensions());
     $this->assertEquals($presence, $validator->getPresenceVerifier());
 }
开发者ID:j-ew-s,项目名称:BabyName,代码行数:17,代码来源:FactoryTest.php

示例10: 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;
     });
 }
开发者ID:Nebo15,项目名称:gandalf.api,代码行数:19,代码来源:ValidationServiceProvider.php

示例11: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->registerPresenceVerifier();
     $this->app->singleton('validator', function ($app) {
         $validator = new Factory($app['translator'], $app);
         // 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']);
         }
         // Add validation extensions
         $extensions = config('esensi/core::validation.extensions', []);
         foreach ($extensions as $extension => $class) {
             $validator->extend($extension, $class . '@validate' . ucfirst(studly_case($extension)));
             $validator->replacer($extension, $class . '@replace' . ucfirst(studly_case($extension)));
         }
         return $validator;
     });
 }
开发者ID:esensi,项目名称:core,代码行数:25,代码来源:ValidationServiceProvider.php

示例12: testBoot

 public function testBoot()
 {
     $translator = Mockery::mock('Symfony\\Component\\Translation\\TranslatorInterface');
     $translator->shouldReceive('get');
     $presence = Mockery::mock('Illuminate\\Validation\\PresenceVerifierInterface');
     $factory = new Factory($translator);
     $factory->setPresenceVerifier($presence);
     $container = Mockery::mock('Illuminate\\Container\\Container');
     $container->shouldReceive('bind');
     $container->shouldReceive('offsetGet')->with('translator')->andReturn($translator);
     $container->shouldReceive('offsetGet')->with('validator')->andReturn($factory);
     $sp = Mockery::mock('Cviebrock\\ImageValidator\\ImageValidatorServiceProvider[package]', array($container));
     $sp->shouldReceive('package');
     $sp->boot();
     $validator = $factory->make(array(), array());
     foreach ($validator->getExtensions() as $rule => $class_and_method) {
         $this->assertTrue(in_array($rule, $sp->getRules()));
         $this->assertEquals('Cviebrock\\ImageValidator\\ImageValidator@' . 'validate' . studly_case($rule), $class_and_method);
         list($class, $method) = Str::parseCallback($class_and_method, null);
         $this->assertTrue(method_exists($class, $method));
     }
 }
开发者ID:arbuuuud,项目名称:gnt-aops,代码行数:22,代码来源:ValidateServiceProviderTest.php

示例13: configureAsExternal

 /**
  * Configures Ardent to be used outside of Laravel - correctly setting Eloquent and Validation modules.
  * @todo Should allow for additional language files. Would probably receive a Translator instance as an optional argument, or a list of translation files.
  *
  * @param array $connection Connection info used by {@link \Illuminate\Database\Capsule\Manager::addConnection}.
  * Should contain driver, host, port, database, username, password, charset and collation.
  */
 public static function configureAsExternal(array $connection)
 {
     $db = new DatabaseCapsule();
     $db->addConnection($connection);
     $db->setEventDispatcher(new Dispatcher(new Container()));
     //TODO: configure a cache manager (as an option)
     // Make this Capsule instance available globally via static methods
     $db->setAsGlobal();
     $db->bootEloquent();
     $translator = new Translator('en');
     $translator->addLoader('file_loader', new PhpFileLoader());
     $translator->addResource('file_loader', dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . 'en' . DIRECTORY_SEPARATOR . 'validation.php', 'en');
     self::$externalValidator = true;
     self::$validationFactory = new ValidationFactory($translator);
     self::$validationFactory->setPresenceVerifier(new DatabasePresenceVerifier($db->getDatabaseManager()));
 }
开发者ID:tatu-carreta,项目名称:mariasanti_v2,代码行数:23,代码来源:Ardent.php

示例14: function

    $validator = $validation->make($data, $rules);
    if ($validator->fails()) {
        $errors = $validator->errors();
    }
    return $app->render('form.php', ['posted' => true, 'errors' => $errors, 'email' => $_POST['email']]);
});
// For a thorough example, we establish a database connection
// to drive the database presence verifier used by the validator.
// If you do not need to validate against values in the database,
// the database presence verifier and related code can be removed.
$app->get('/database', function () use($app) {
    return $app->render('form.php', ['posted' => false, 'errors' => null, 'email' => '']);
});
$app->post('/database', function () use($app) {
    $capsule = new Capsule();
    $capsule->addConnection(['driver' => 'mysql', 'host' => 'localhost', 'database' => 'illuminate_non_laravel', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '']);
    $loader = new FileLoader(new Filesystem(), 'lang');
    $translator = new Translator($loader, 'en');
    $presence = new DatabasePresenceVerifier($capsule->getDatabaseManager());
    $validation = new Factory($translator, new Container());
    $validation->setPresenceVerifier($presence);
    $data = ['email' => $_POST['email']];
    $rules = ['email' => 'required|email|unique:users'];
    $errors = null;
    $validator = $validation->make($data, $rules);
    if ($validator->fails()) {
        $errors = $validator->errors();
    }
    return $app->render('form.php', ['posted' => true, 'errors' => $errors, 'email' => $_POST['email']]);
});
$app->run();
开发者ID:hskrasek,项目名称:IlluminateNonLaravel,代码行数:31,代码来源:index.php

示例15: createIlluminateDriver

 /**
  * Create an instance of the Illuminate validation driver.
  *
  * @return \Deefour\Aide\Validation\AbstractValidator
  */
 protected function createIlluminateDriver()
 {
     $factory = new IlluminateFactory($this->app['translator'], $this->app);
     $factory->setPresenceVerifier($this->app['validation.presence']);
     return new IlluminateValidator($factory);
 }
开发者ID:deefour,项目名称:aide,代码行数:11,代码来源:ValidationManager.php


注:本文中的Illuminate\Validation\Factory::setPresenceVerifier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。