本文整理汇总了PHP中Illuminate\Foundation\Application::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getInstance方法的具体用法?PHP Application::getInstance怎么用?PHP Application::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Foundation\Application
的用法示例。
在下文中一共展示了Application::getInstance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createValidator
/**
* 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);
}
示例2: registerClosure
/**
* 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: file
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: getInstance
/**
* 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: __construct
public function __construct($items = [], $addons = null)
{
parent::__construct($items);
$this->app = \Illuminate\Foundation\Application::getInstance();
$this->addons = $addons ?: $this->app->make('codex.addons');
}
示例6: getLocale
/**
* @return string
* @author Rytis Grincevičius <rytis.grincevicius@gmail.com>
*/
public static function getLocale()
{
return Application::getInstance()->getLocale();
}
示例7: translation_path
/**
* @param string $path
* @param string $locale
* @return string
* @author Rytis Grincevičius <rytis.grincevicius@gmail.com>
*/
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));
}