/**
  * Function creates validator object using IoC calls
  *
  * @return AbstractValidator
  * @throws Exception
  */
 protected static function createValidator()
 {
     $className = self::getValidatorClass();
     if (!class_exists($className)) {
         throw new Exception("Cannot load validator class '{$className}' for model '" . static::class . "'");
     }
     return Application::getInstance()->make($className);
 }
 /**
  * Registers provided closure as a validation rule. Useful for quick & dirty validation
  *
  * @param string              $ruleName
  * @param string|Closure      $validateFunction
  * @param string|Closure|null $replaceFunction
  */
 public static function registerClosure($ruleName, $validateFunction, $replaceFunction = null)
 {
     /** @var Factory $validatorFactory */
     $validatorFactory = Application::getInstance()->make(Factory::class);
     $validatorFactory->extend($ruleName, $validateFunction);
     if (null !== $replaceFunction) {
         $validatorFactory->replacer($ruleName, $replaceFunction);
     }
 }
예제 #3
0
파일: Pinyin.php 프로젝트: ruby97/faker
 function __construct()
 {
     $filePath = Application::getInstance()->storagePath() . '/files/pinyin.db';
     if (file_exists($filePath)) {
         $records = file($filePath);
         foreach ($records as $record) {
             $record = trim($record);
             $this->map[substr($record, 0, 3)] = substr($record, 4, strlen($record) - 3);
         }
     }
 }
예제 #4
0
 /**
  * Set the globally available instance of the container.
  *
  * @return static 
  * @static 
  */
 public static function getInstance()
 {
     //Method inherited from \Illuminate\Container\Container
     return \Illuminate\Foundation\Application::getInstance();
 }
예제 #5
0
 public function __construct($items = [], $addons = null)
 {
     parent::__construct($items);
     $this->app = \Illuminate\Foundation\Application::getInstance();
     $this->addons = $addons ?: $this->app->make('codex.addons');
 }
예제 #6
0
 /**
  * @return string
  * @author Rytis Grincevičius <*****@*****.**>
  */
 public static function getLocale()
 {
     return Application::getInstance()->getLocale();
 }
예제 #7
0
 /**
  * @param string $path
  * @param string $locale
  * @return string
  * @author Rytis Grincevičius <*****@*****.**>
  */
 public static function translation_path($path = '', $locale = '')
 {
     $locale = $locale ? $locale : Application::getInstance()->getLocale();
     $path = self::parse_path($path);
     return self::translations_path($locale . ($path ? DIRECTORY_SEPARATOR . $path : $path));
 }