updated packages
This commit is contained in:
2
vendor/laravel/framework/README.md
vendored
2
vendor/laravel/framework/README.md
vendored
@@ -20,7 +20,7 @@ Laravel is a web application framework with expressive, elegant syntax. We belie
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
|
||||
Laravel is accessible, yet powerful, providing tools needed for large, robust applications. A superb combination of simplicity, elegance, and innovation gives you a complete toolset required to build any application with which you are tasked
|
||||
Laravel is accessible, yet powerful, providing tools needed for large, robust applications. A superb combination of simplicity, elegance, and innovation gives you a complete toolset required to build any application with which you are tasked.
|
||||
|
||||
## Learning Laravel
|
||||
|
||||
|
||||
45
vendor/laravel/framework/composer.json
vendored
45
vendor/laravel/framework/composer.json
vendored
@@ -16,31 +16,31 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-openssl": "*",
|
||||
"doctrine/inflector": "^1.1",
|
||||
"dragonmantank/cron-expression": "^2.0",
|
||||
"egulias/email-validator": "^2.0",
|
||||
"erusev/parsedown": "^1.7",
|
||||
"laravel/nexmo-notification-channel": "^1.0",
|
||||
"laravel/slack-notification-channel": "^1.0",
|
||||
"league/flysystem": "^1.0.8",
|
||||
"monolog/monolog": "^1.12",
|
||||
"nesbot/carbon": "^1.26.3",
|
||||
"nesbot/carbon": "^1.26.3 || ^2.0",
|
||||
"opis/closure": "^3.1",
|
||||
"psr/container": "^1.0",
|
||||
"psr/simple-cache": "^1.0",
|
||||
"ramsey/uuid": "^3.7",
|
||||
"swiftmailer/swiftmailer": "^6.0",
|
||||
"symfony/console": "^4.1",
|
||||
"symfony/debug": "^4.1",
|
||||
"symfony/finder": "^4.1",
|
||||
"symfony/http-foundation": "^4.1",
|
||||
"symfony/http-kernel": "^4.1",
|
||||
"symfony/process": "^4.1",
|
||||
"symfony/routing": "^4.1",
|
||||
"symfony/var-dumper": "^4.1",
|
||||
"symfony/console": "^4.2",
|
||||
"symfony/debug": "^4.2",
|
||||
"symfony/finder": "^4.2",
|
||||
"symfony/http-foundation": "^4.2",
|
||||
"symfony/http-kernel": "^4.2",
|
||||
"symfony/process": "^4.2",
|
||||
"symfony/routing": "^4.2",
|
||||
"symfony/var-dumper": "^4.2",
|
||||
"tijsverkoyen/css-to-inline-styles": "^2.2.1",
|
||||
"vlucas/phpdotenv": "^2.2"
|
||||
"vlucas/phpdotenv": "^3.3"
|
||||
},
|
||||
"replace": {
|
||||
"illuminate/auth": "self.version",
|
||||
@@ -83,12 +83,12 @@
|
||||
"league/flysystem-cached-adapter": "^1.0",
|
||||
"mockery/mockery": "^1.0",
|
||||
"moontoast/math": "^1.1",
|
||||
"orchestra/testbench-core": "3.7.*",
|
||||
"pda/pheanstalk": "^3.0",
|
||||
"phpunit/phpunit": "^7.5",
|
||||
"orchestra/testbench-core": "3.8.*",
|
||||
"pda/pheanstalk": "^4.0",
|
||||
"phpunit/phpunit": "^7.5|^8.0",
|
||||
"predis/predis": "^1.1.1",
|
||||
"symfony/css-selector": "^4.1",
|
||||
"symfony/dom-crawler": "^4.1",
|
||||
"symfony/css-selector": "^4.2",
|
||||
"symfony/dom-crawler": "^4.2",
|
||||
"true/punycode": "^2.1"
|
||||
},
|
||||
"autoload": {
|
||||
@@ -110,7 +110,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.7-dev"
|
||||
"dev-master": "5.8-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
@@ -128,12 +128,13 @@
|
||||
"league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^1.0).",
|
||||
"moontoast/math": "Required to use ordered UUIDs (^1.1).",
|
||||
"nexmo/client": "Required to use the Nexmo transport (^1.0).",
|
||||
"pda/pheanstalk": "Required to use the beanstalk queue driver (^3.0).",
|
||||
"pda/pheanstalk": "Required to use the beanstalk queue driver (^4.0).",
|
||||
"predis/predis": "Required to use the redis cache and queue drivers (^1.0).",
|
||||
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^3.0).",
|
||||
"symfony/css-selector": "Required to use some of the crawler integration testing tools (^4.1).",
|
||||
"symfony/dom-crawler": "Required to use most of the crawler integration testing tools (^4.1).",
|
||||
"symfony/psr-http-message-bridge": "Required to psr7 bridging features (^1.0)."
|
||||
"symfony/css-selector": "Required to use some of the crawler integration testing tools (^4.2).",
|
||||
"symfony/dom-crawler": "Required to use most of the crawler integration testing tools (^4.2).",
|
||||
"symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^1.1).",
|
||||
"wildbit/swiftmailer-postmark": "Required to use Postmark mail driver (^3.0)."
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
|
||||
@@ -57,6 +57,20 @@ class Gate implements GateContract
|
||||
*/
|
||||
protected $afterCallbacks = [];
|
||||
|
||||
/**
|
||||
* All of the defined abilities using class@method notation.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $stringCallbacks = [];
|
||||
|
||||
/**
|
||||
* The callback to be used to guess policy names.
|
||||
*
|
||||
* @var callable|null
|
||||
*/
|
||||
protected $guessPolicyNamesUsingCallback;
|
||||
|
||||
/**
|
||||
* Create a new gate instance.
|
||||
*
|
||||
@@ -66,10 +80,12 @@ class Gate implements GateContract
|
||||
* @param array $policies
|
||||
* @param array $beforeCallbacks
|
||||
* @param array $afterCallbacks
|
||||
* @param callable|null $guessPolicyNamesUsingCallback
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Container $container, callable $userResolver, array $abilities = [],
|
||||
array $policies = [], array $beforeCallbacks = [], array $afterCallbacks = [])
|
||||
array $policies = [], array $beforeCallbacks = [], array $afterCallbacks = [],
|
||||
callable $guessPolicyNamesUsingCallback = null)
|
||||
{
|
||||
$this->policies = $policies;
|
||||
$this->container = $container;
|
||||
@@ -77,6 +93,7 @@ class Gate implements GateContract
|
||||
$this->userResolver = $userResolver;
|
||||
$this->afterCallbacks = $afterCallbacks;
|
||||
$this->beforeCallbacks = $beforeCallbacks;
|
||||
$this->guessPolicyNamesUsingCallback = $guessPolicyNamesUsingCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,6 +129,8 @@ class Gate implements GateContract
|
||||
if (is_callable($callback)) {
|
||||
$this->abilities[$ability] = $callback;
|
||||
} elseif (is_string($callback)) {
|
||||
$this->stringCallbacks[$ability] = $callback;
|
||||
|
||||
$this->abilities[$ability] = $this->buildAbilityCallback($ability, $callback);
|
||||
} else {
|
||||
throw new InvalidArgumentException("Callback must be a callable or a 'Class@method' string.");
|
||||
@@ -276,6 +295,18 @@ class Gate implements GateContract
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if all of the given abilities should be denied for the current user.
|
||||
*
|
||||
* @param iterable|string $abilities
|
||||
* @param array|mixed $arguments
|
||||
* @return bool
|
||||
*/
|
||||
public function none($abilities, $arguments = [])
|
||||
{
|
||||
return ! $this->any($abilities, $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given ability should be granted for the current user.
|
||||
*
|
||||
@@ -431,14 +462,12 @@ class Gate implements GateContract
|
||||
*/
|
||||
protected function callBeforeCallbacks($user, $ability, array $arguments)
|
||||
{
|
||||
$arguments = array_merge([$user, $ability], [$arguments]);
|
||||
|
||||
foreach ($this->beforeCallbacks as $before) {
|
||||
if (! $this->canBeCalledWithUser($user, $before)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! is_null($result = $before(...$arguments))) {
|
||||
if (! is_null($result = $before($user, $ability, $arguments))) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -484,13 +513,20 @@ class Gate implements GateContract
|
||||
return $callback;
|
||||
}
|
||||
|
||||
if (isset($this->stringCallbacks[$ability])) {
|
||||
[$class, $method] = Str::parseCallback($this->stringCallbacks[$ability]);
|
||||
|
||||
if ($this->canBeCalledWithUser($user, $class, $method ?: '__invoke')) {
|
||||
return $this->abilities[$ability];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->abilities[$ability]) &&
|
||||
$this->canBeCalledWithUser($user, $this->abilities[$ability])) {
|
||||
return $this->abilities[$ability];
|
||||
}
|
||||
|
||||
return function () {
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -514,6 +550,12 @@ class Gate implements GateContract
|
||||
return $this->resolvePolicy($this->policies[$class]);
|
||||
}
|
||||
|
||||
foreach ($this->guessPolicyName($class) as $guessedPolicy) {
|
||||
if (class_exists($guessedPolicy)) {
|
||||
return $this->resolvePolicy($guessedPolicy);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->policies as $expected => $policy) {
|
||||
if (is_subclass_of($class, $expected)) {
|
||||
return $this->resolvePolicy($policy);
|
||||
@@ -521,6 +563,36 @@ class Gate implements GateContract
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Guess the policy name for the given class.
|
||||
*
|
||||
* @param string $class
|
||||
* @return array
|
||||
*/
|
||||
protected function guessPolicyName($class)
|
||||
{
|
||||
if ($this->guessPolicyNamesUsingCallback) {
|
||||
return Arr::wrap(call_user_func($this->guessPolicyNamesUsingCallback, $class));
|
||||
}
|
||||
|
||||
$classDirname = str_replace('/', '\\', dirname(str_replace('\\', '/', $class)));
|
||||
|
||||
return [$classDirname.'\\Policies\\'.class_basename($class).'Policy'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a callback to be used to guess policy names.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function guessPolicyNamesUsing(callable $callback)
|
||||
{
|
||||
$this->guessPolicyNamesUsingCallback = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a policy class instance of the given type.
|
||||
*
|
||||
@@ -580,7 +652,7 @@ class Gate implements GateContract
|
||||
protected function callPolicyBefore($policy, $user, $ability, $arguments)
|
||||
{
|
||||
if (! method_exists($policy, 'before')) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->canBeCalledWithUser($user, $policy, 'before')) {
|
||||
@@ -607,7 +679,7 @@ class Gate implements GateContract
|
||||
}
|
||||
|
||||
if (! is_callable([$policy, $method])) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->canBeCalledWithUser($user, $policy, $method)) {
|
||||
@@ -640,7 +712,8 @@ class Gate implements GateContract
|
||||
|
||||
return new static(
|
||||
$this->container, $callback, $this->abilities,
|
||||
$this->policies, $this->beforeCallbacks, $this->afterCallbacks
|
||||
$this->policies, $this->beforeCallbacks, $this->afterCallbacks,
|
||||
$this->guessPolicyNamesUsingCallback
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
13
vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php
vendored
Normal file → Executable file
13
vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php
vendored
Normal file → Executable file
@@ -13,7 +13,7 @@ class AuthManager implements FactoryContract
|
||||
/**
|
||||
* The application instance.
|
||||
*
|
||||
* @var \Illuminate\Foundation\Application
|
||||
* @var \Illuminate\Contracts\Foundation\Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
@@ -43,7 +43,7 @@ class AuthManager implements FactoryContract
|
||||
/**
|
||||
* Create a new Auth manager instance.
|
||||
*
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($app)
|
||||
@@ -94,7 +94,9 @@ class AuthManager implements FactoryContract
|
||||
return $this->{$driverMethod}($name, $config);
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException("Auth driver [{$config['driver']}] for guard [{$name}] is not defined.");
|
||||
throw new InvalidArgumentException(
|
||||
"Auth driver [{$config['driver']}] for guard [{$name}] is not defined."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,7 +156,10 @@ class AuthManager implements FactoryContract
|
||||
// user in the database or another persistence layer where users are.
|
||||
$guard = new TokenGuard(
|
||||
$this->createUserProvider($config['provider'] ?? null),
|
||||
$this->app['request']
|
||||
$this->app['request'],
|
||||
$config['input_key'] ?? 'api_token',
|
||||
$config['storage_key'] ?? 'api_token',
|
||||
$config['hash'] ?? false
|
||||
);
|
||||
|
||||
$this->app->refresh('request', $guard, 'setRequest');
|
||||
|
||||
24
vendor/laravel/framework/src/Illuminate/Auth/AuthServiceProvider.php
vendored
Normal file → Executable file
24
vendor/laravel/framework/src/Illuminate/Auth/AuthServiceProvider.php
vendored
Normal file → Executable file
@@ -17,12 +17,10 @@ class AuthServiceProvider extends ServiceProvider
|
||||
public function register()
|
||||
{
|
||||
$this->registerAuthenticator();
|
||||
|
||||
$this->registerUserResolver();
|
||||
|
||||
$this->registerAccessGate();
|
||||
|
||||
$this->registerRequestRebindHandler();
|
||||
$this->registerEventRebindHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +73,7 @@ class AuthServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a resolver for the authenticated user.
|
||||
* Handle the re-binding of the request binding.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -87,4 +85,22 @@ class AuthServiceProvider extends ServiceProvider
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the re-binding of the event dispatcher binding.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerEventRebindHandler()
|
||||
{
|
||||
$this->app->rebinding('events', function ($app, $dispatcher) {
|
||||
if (! $app->resolved('auth')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (method_exists($guard = $app['auth']->guard(), 'setDispatcher')) {
|
||||
$guard->setDispatcher($dispatcher);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,11 +74,11 @@ class AuthMakeCommand extends Command
|
||||
*/
|
||||
protected function createDirectories()
|
||||
{
|
||||
if (! is_dir($directory = resource_path('views/layouts'))) {
|
||||
if (! is_dir($directory = $this->getViewPath('layouts'))) {
|
||||
mkdir($directory, 0755, true);
|
||||
}
|
||||
|
||||
if (! is_dir($directory = resource_path('views/auth/passwords'))) {
|
||||
if (! is_dir($directory = $this->getViewPath('auth/passwords'))) {
|
||||
mkdir($directory, 0755, true);
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ class AuthMakeCommand extends Command
|
||||
protected function exportViews()
|
||||
{
|
||||
foreach ($this->views as $key => $value) {
|
||||
if (file_exists($view = resource_path('views/'.$value)) && ! $this->option('force')) {
|
||||
if (file_exists($view = $this->getViewPath($value)) && ! $this->option('force')) {
|
||||
if (! $this->confirm("The [{$value}] view already exists. Do you want to replace it?")) {
|
||||
continue;
|
||||
}
|
||||
@@ -117,4 +117,16 @@ class AuthMakeCommand extends Command
|
||||
file_get_contents(__DIR__.'/stubs/make/controllers/HomeController.stub')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full view path relative to the app's configured view path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getViewPath($path)
|
||||
{
|
||||
return implode(DIRECTORY_SEPARATOR, [
|
||||
config('view.paths')[0] ?? resource_path('views'), $path,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required autofocus>
|
||||
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
|
||||
|
||||
@if ($errors->has('email'))
|
||||
@error('email')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $errors->first('email') }}</strong>
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -29,13 +29,13 @@
|
||||
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required>
|
||||
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="current-password">
|
||||
|
||||
@if ($errors->has('password'))
|
||||
@error('password')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $errors->first('password') }}</strong>
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required>
|
||||
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
|
||||
|
||||
@if ($errors->has('email'))
|
||||
@error('email')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $errors->first('email') }}</strong>
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ $email ?? old('email') }}" required autofocus>
|
||||
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ $email ?? old('email') }}" required autocomplete="email" autofocus>
|
||||
|
||||
@if ($errors->has('email'))
|
||||
@error('email')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $errors->first('email') }}</strong>
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -31,13 +31,13 @@
|
||||
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required>
|
||||
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="new-password">
|
||||
|
||||
@if ($errors->has('password'))
|
||||
@error('password')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $errors->first('password') }}</strong>
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
|
||||
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
<label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Name') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="name" type="text" class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" name="name" value="{{ old('name') }}" required autofocus>
|
||||
<input id="name" type="text" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
|
||||
|
||||
@if ($errors->has('name'))
|
||||
@error('name')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $errors->first('name') }}</strong>
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -29,13 +29,13 @@
|
||||
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required>
|
||||
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email">
|
||||
|
||||
@if ($errors->has('email'))
|
||||
@error('email')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $errors->first('email') }}</strong>
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -43,13 +43,13 @@
|
||||
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required>
|
||||
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="new-password">
|
||||
|
||||
@if ($errors->has('password'))
|
||||
@error('password')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $errors->first('password') }}</strong>
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@endif
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
|
||||
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<nav class="navbar navbar-expand-md navbar-light navbar-laravel">
|
||||
<nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="{{ url('/') }}">
|
||||
{{ config('app.name', 'Laravel') }}
|
||||
|
||||
0
vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php
vendored
Normal file → Executable file
34
vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php
vendored
Normal file → Executable file
34
vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php
vendored
Normal file → Executable file
@@ -47,9 +47,9 @@ class EloquentUserProvider implements UserProvider
|
||||
{
|
||||
$model = $this->createModel();
|
||||
|
||||
return $model->newQuery()
|
||||
->where($model->getAuthIdentifierName(), $identifier)
|
||||
->first();
|
||||
return $this->newModelQuery($model)
|
||||
->where($model->getAuthIdentifierName(), $identifier)
|
||||
->first();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,15 +63,18 @@ class EloquentUserProvider implements UserProvider
|
||||
{
|
||||
$model = $this->createModel();
|
||||
|
||||
$model = $model->where($model->getAuthIdentifierName(), $identifier)->first();
|
||||
$retrievedModel = $this->newModelQuery($model)->where(
|
||||
$model->getAuthIdentifierName(), $identifier
|
||||
)->first();
|
||||
|
||||
if (! $model) {
|
||||
return null;
|
||||
if (! $retrievedModel) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rememberToken = $model->getRememberToken();
|
||||
$rememberToken = $retrievedModel->getRememberToken();
|
||||
|
||||
return $rememberToken && hash_equals($rememberToken, $token) ? $model : null;
|
||||
return $rememberToken && hash_equals($rememberToken, $token)
|
||||
? $retrievedModel : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +114,7 @@ class EloquentUserProvider implements UserProvider
|
||||
// First we will add each credential element to the query as a where clause.
|
||||
// Then we can execute the query and, if we found a user, return it in a
|
||||
// Eloquent User "model" that will be utilized by the Guard instances.
|
||||
$query = $this->createModel()->newQuery();
|
||||
$query = $this->newModelQuery();
|
||||
|
||||
foreach ($credentials as $key => $value) {
|
||||
if (Str::contains($key, 'password')) {
|
||||
@@ -142,6 +145,19 @@ class EloquentUserProvider implements UserProvider
|
||||
return $this->hasher->check($plain, $user->getAuthPassword());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a new query builder for the model instance.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model|null $model
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
protected function newModelQuery($model = null)
|
||||
{
|
||||
return is_null($model)
|
||||
? $this->createModel()->newQuery()
|
||||
: $model->newQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of the model.
|
||||
*
|
||||
|
||||
37
vendor/laravel/framework/src/Illuminate/Auth/Events/OtherDeviceLogout.php
vendored
Normal file
37
vendor/laravel/framework/src/Illuminate/Auth/Events/OtherDeviceLogout.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class OtherDeviceLogout
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The authentication guard name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $guard;
|
||||
|
||||
/**
|
||||
* The authenticated user.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param string $guard
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($guard, $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->guard = $guard;
|
||||
}
|
||||
}
|
||||
0
vendor/laravel/framework/src/Illuminate/Auth/GenericUser.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Auth/GenericUser.php
vendored
Normal file → Executable file
@@ -33,9 +33,13 @@ class AuthenticateWithBasicAuth
|
||||
* @param string|null $guard
|
||||
* @param string|null $field
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null, $field = null)
|
||||
{
|
||||
return $this->auth->guard($guard)->basic($field ?: 'email') ?: $next($request);
|
||||
$this->auth->guard($guard)->basic($field ?: 'email');
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,12 @@ class Authorize
|
||||
*/
|
||||
protected function getModel($request, $model)
|
||||
{
|
||||
return $this->isClassName($model) ? trim($model) : $request->route($model, $model);
|
||||
if ($this->isClassName($model)) {
|
||||
return trim($model);
|
||||
} else {
|
||||
return $request->route($model, null) ?:
|
||||
((preg_match("/^['\"](.*)['\"]$/", trim($model), $matches)) ? $matches[1] : null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,16 +13,17 @@ class EnsureEmailIsVerified
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string $redirectToRoute
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
public function handle($request, Closure $next, $redirectToRoute = null)
|
||||
{
|
||||
if (! $request->user() ||
|
||||
($request->user() instanceof MustVerifyEmail &&
|
||||
! $request->user()->hasVerifiedEmail())) {
|
||||
return $request->expectsJson()
|
||||
? abort(403, 'Your email address is not verified.')
|
||||
: Redirect::route('verification.notice');
|
||||
: Redirect::route($redirectToRoute ?: 'verification.notice');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
@@ -59,7 +59,8 @@ class ResetPassword extends Notification
|
||||
return (new MailMessage)
|
||||
->subject(Lang::getFromJson('Reset Password Notification'))
|
||||
->line(Lang::getFromJson('You are receiving this email because we received a password reset request for your account.'))
|
||||
->action(Lang::getFromJson('Reset Password'), url(config('app.url').route('password.reset', $this->token, false)))
|
||||
->action(Lang::getFromJson('Reset Password'), url(config('app.url').route('password.reset', ['token' => $this->token, 'email' => $notifiable->getEmailForPasswordReset()], false)))
|
||||
->line(Lang::getFromJson('This password reset link will expire in :count minutes.', ['count' => config('auth.passwords.users.expire')]))
|
||||
->line(Lang::getFromJson('If you did not request a password reset, no further action is required.'));
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Illuminate\Auth\Notifications;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
@@ -36,17 +37,16 @@ class VerifyEmail extends Notification
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$verificationUrl = $this->verificationUrl($notifiable);
|
||||
|
||||
if (static::$toMailCallback) {
|
||||
return call_user_func(static::$toMailCallback, $notifiable);
|
||||
return call_user_func(static::$toMailCallback, $notifiable, $verificationUrl);
|
||||
}
|
||||
|
||||
return (new MailMessage)
|
||||
->subject(Lang::getFromJson('Verify Email Address'))
|
||||
->line(Lang::getFromJson('Please click the button below to verify your email address.'))
|
||||
->action(
|
||||
Lang::getFromJson('Verify Email Address'),
|
||||
$this->verificationUrl($notifiable)
|
||||
)
|
||||
->action(Lang::getFromJson('Verify Email Address'), $verificationUrl)
|
||||
->line(Lang::getFromJson('If you did not create an account, no further action is required.'));
|
||||
}
|
||||
|
||||
@@ -59,7 +59,9 @@ class VerifyEmail extends Notification
|
||||
protected function verificationUrl($notifiable)
|
||||
{
|
||||
return URL::temporarySignedRoute(
|
||||
'verification.verify', Carbon::now()->addMinutes(60), ['id' => $notifiable->getKey()]
|
||||
'verification.verify',
|
||||
Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)),
|
||||
['id' => $notifiable->getKey()]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
0
vendor/laravel/framework/src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php
vendored
Normal file → Executable file
2
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
vendored
Normal file → Executable file
2
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
vendored
Normal file → Executable file
@@ -172,7 +172,7 @@ class PasswordBroker implements PasswordBrokerContract
|
||||
$credentials['password_confirmation'],
|
||||
];
|
||||
|
||||
return $password === $confirm && mb_strlen($password) >= 6;
|
||||
return $password === $confirm && mb_strlen($password) >= 8;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,7 @@ class PasswordBrokerManager implements FactoryContract
|
||||
/**
|
||||
* The application instance.
|
||||
*
|
||||
* @var \Illuminate\Foundation\Application
|
||||
* @var \Illuminate\Contracts\Foundation\Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
@@ -28,7 +28,7 @@ class PasswordBrokerManager implements FactoryContract
|
||||
/**
|
||||
* Create a new PasswordBroker manager instance.
|
||||
*
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($app)
|
||||
@@ -46,9 +46,7 @@ class PasswordBrokerManager implements FactoryContract
|
||||
{
|
||||
$name = $name ?: $this->getDefaultDriver();
|
||||
|
||||
return isset($this->brokers[$name])
|
||||
? $this->brokers[$name]
|
||||
: $this->brokers[$name] = $this->resolve($name);
|
||||
return $this->brokers[$name] ?? ($this->brokers[$name] = $this->resolve($name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
10
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordResetServiceProvider.php
vendored
Normal file → Executable file
10
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordResetServiceProvider.php
vendored
Normal file → Executable file
@@ -3,16 +3,10 @@
|
||||
namespace Illuminate\Auth\Passwords;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Contracts\Support\DeferrableProvider;
|
||||
|
||||
class PasswordResetServiceProvider extends ServiceProvider
|
||||
class PasswordResetServiceProvider extends ServiceProvider implements DeferrableProvider
|
||||
{
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $defer = true;
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
|
||||
0
vendor/laravel/framework/src/Illuminate/Auth/Passwords/TokenRepositoryInterface.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Auth/Passwords/TokenRepositoryInterface.php
vendored
Normal file → Executable file
@@ -135,9 +135,7 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
// If the user is null, but we decrypt a "recaller" cookie we can attempt to
|
||||
// pull the user data on that cookie which serves as a remember cookie on
|
||||
// the application. Once we have a user we can return it to the caller.
|
||||
$recaller = $this->recaller();
|
||||
|
||||
if (is_null($this->user) && ! is_null($recaller)) {
|
||||
if (is_null($this->user) && ! is_null($recaller = $this->recaller())) {
|
||||
$this->user = $this->userFromRecaller($recaller);
|
||||
|
||||
if ($this->user) {
|
||||
@@ -489,7 +487,7 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
// listening for anytime a user signs out of this application manually.
|
||||
$this->clearUserDataFromStorage();
|
||||
|
||||
if (! is_null($this->user)) {
|
||||
if (! is_null($this->user) && ! empty($user->getRememberToken())) {
|
||||
$this->cycleRememberToken($user);
|
||||
}
|
||||
|
||||
@@ -552,7 +550,12 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
$attribute => Hash::make($password),
|
||||
]))->save();
|
||||
|
||||
$this->queueRecallerCookie($this->user());
|
||||
if ($this->recaller() ||
|
||||
$this->getCookieJar()->hasQueued($this->getRecallerName())) {
|
||||
$this->queueRecallerCookie($this->user());
|
||||
}
|
||||
|
||||
$this->fireOtherDeviceLogoutEvent($this->user());
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -617,6 +620,21 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire the other device logout event if the dispatcher is set.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
protected function fireOtherDeviceLogoutEvent($user)
|
||||
{
|
||||
if (isset($this->events)) {
|
||||
$this->events->dispatch(new Events\OtherDeviceLogout(
|
||||
$this->name, $user
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire the failed authentication attempt event with the given arguments.
|
||||
*
|
||||
|
||||
@@ -31,6 +31,13 @@ class TokenGuard implements Guard
|
||||
*/
|
||||
protected $storageKey;
|
||||
|
||||
/**
|
||||
* Indicates if the API token is hashed in storage.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $hash = false;
|
||||
|
||||
/**
|
||||
* Create a new authentication guard.
|
||||
*
|
||||
@@ -38,10 +45,17 @@ class TokenGuard implements Guard
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string $inputKey
|
||||
* @param string $storageKey
|
||||
* @param bool $hash
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(UserProvider $provider, Request $request, $inputKey = 'api_token', $storageKey = 'api_token')
|
||||
public function __construct(
|
||||
UserProvider $provider,
|
||||
Request $request,
|
||||
$inputKey = 'api_token',
|
||||
$storageKey = 'api_token',
|
||||
$hash = false)
|
||||
{
|
||||
$this->hash = $hash;
|
||||
$this->request = $request;
|
||||
$this->provider = $provider;
|
||||
$this->inputKey = $inputKey;
|
||||
@@ -67,9 +81,9 @@ class TokenGuard implements Guard
|
||||
$token = $this->getTokenForRequest();
|
||||
|
||||
if (! empty($token)) {
|
||||
$user = $this->provider->retrieveByCredentials(
|
||||
[$this->storageKey => $token]
|
||||
);
|
||||
$user = $this->provider->retrieveByCredentials([
|
||||
$this->storageKey => $this->hash ? hash('sha256', $token) : $token,
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->user = $user;
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"illuminate/contracts": "5.7.*",
|
||||
"illuminate/http": "5.7.*",
|
||||
"illuminate/queue": "5.7.*",
|
||||
"illuminate/support": "5.7.*"
|
||||
"illuminate/contracts": "5.8.*",
|
||||
"illuminate/http": "5.8.*",
|
||||
"illuminate/queue": "5.8.*",
|
||||
"illuminate/support": "5.8.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -27,13 +27,13 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.7-dev"
|
||||
"dev-master": "5.8-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"illuminate/console": "Required to use the auth:clear-resets command (5.7.*).",
|
||||
"illuminate/queue": "Required to fire login / logout events (5.7.*).",
|
||||
"illuminate/session": "Required to use the session based guard (5.7.*)."
|
||||
"illuminate/console": "Required to use the auth:clear-resets command (5.8.*).",
|
||||
"illuminate/queue": "Required to fire login / logout events (5.8.*).",
|
||||
"illuminate/session": "Required to use the session based guard (5.8.*)."
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
|
||||
@@ -16,6 +16,10 @@ class BroadcastController extends Controller
|
||||
*/
|
||||
public function authenticate(Request $request)
|
||||
{
|
||||
if ($request->hasSession()) {
|
||||
$request->session()->reflash();
|
||||
}
|
||||
|
||||
return Broadcast::auth($request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class BroadcastManager implements FactoryContract
|
||||
/**
|
||||
* The application instance.
|
||||
*
|
||||
* @var \Illuminate\Foundation\Application
|
||||
* @var \Illuminate\Contracts\Foundation\Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
@@ -42,7 +42,7 @@ class BroadcastManager implements FactoryContract
|
||||
/**
|
||||
* Create a new manager instance.
|
||||
*
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($app)
|
||||
@@ -165,7 +165,7 @@ class BroadcastManager implements FactoryContract
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the given store.
|
||||
* Resolve the given broadcaster.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \Illuminate\Contracts\Broadcasting\Broadcaster
|
||||
@@ -176,10 +176,6 @@ class BroadcastManager implements FactoryContract
|
||||
{
|
||||
$config = $this->getConfig($name);
|
||||
|
||||
if (is_null($config)) {
|
||||
throw new InvalidArgumentException("Broadcaster [{$name}] is not defined.");
|
||||
}
|
||||
|
||||
if (isset($this->customCreators[$config['driver']])) {
|
||||
return $this->callCustomCreator($config);
|
||||
}
|
||||
@@ -269,7 +265,11 @@ class BroadcastManager implements FactoryContract
|
||||
*/
|
||||
protected function getConfig($name)
|
||||
{
|
||||
return $this->app['config']["broadcasting.connections.{$name}"];
|
||||
if (! is_null($name) && $name !== 'null') {
|
||||
return $this->app['config']["broadcasting.connections.{$name}"];
|
||||
}
|
||||
|
||||
return ['driver' => 'null'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,18 +3,12 @@
|
||||
namespace Illuminate\Broadcasting;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Contracts\Support\DeferrableProvider;
|
||||
use Illuminate\Contracts\Broadcasting\Factory as BroadcastingFactory;
|
||||
use Illuminate\Contracts\Broadcasting\Broadcaster as BroadcasterContract;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
class BroadcastServiceProvider extends ServiceProvider implements DeferrableProvider
|
||||
{
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $defer = true;
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Illuminate\Broadcasting\Broadcasters;
|
||||
use Exception;
|
||||
use ReflectionClass;
|
||||
use ReflectionFunction;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Contracts\Routing\UrlRoutable;
|
||||
@@ -21,6 +22,13 @@ abstract class Broadcaster implements BroadcasterContract
|
||||
*/
|
||||
protected $channels = [];
|
||||
|
||||
/**
|
||||
* The registered channel options.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $channelOptions = [];
|
||||
|
||||
/**
|
||||
* The binding registrar instance.
|
||||
*
|
||||
@@ -33,12 +41,15 @@ abstract class Broadcaster implements BroadcasterContract
|
||||
*
|
||||
* @param string $channel
|
||||
* @param callable|string $callback
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function channel($channel, $callback)
|
||||
public function channel($channel, $callback, $options = [])
|
||||
{
|
||||
$this->channels[$channel] = $callback;
|
||||
|
||||
$this->channelOptions[$channel] = $options;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -54,7 +65,7 @@ abstract class Broadcaster implements BroadcasterContract
|
||||
protected function verifyUserCanAccessChannel($request, $channel)
|
||||
{
|
||||
foreach ($this->channels as $pattern => $callback) {
|
||||
if (! Str::is(preg_replace('/\{(.*?)\}/', '*', $pattern), $channel)) {
|
||||
if (! $this->channelNameMatchesPattern($channel, $pattern)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -62,7 +73,7 @@ abstract class Broadcaster implements BroadcasterContract
|
||||
|
||||
$handler = $this->normalizeChannelHandlerToCallable($callback);
|
||||
|
||||
if ($result = $handler($request->user(), ...$parameters)) {
|
||||
if ($result = $handler($this->retrieveUser($request, $channel), ...$parameters)) {
|
||||
return $this->validAuthenticationResponse($request, $result);
|
||||
}
|
||||
}
|
||||
@@ -260,4 +271,59 @@ abstract class Broadcaster implements BroadcasterContract
|
||||
->join(...$args);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the authenticated user using the configured guard (if any).
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string $channel
|
||||
* @return mixed
|
||||
*/
|
||||
protected function retrieveUser($request, $channel)
|
||||
{
|
||||
$options = $this->retrieveChannelOptions($channel);
|
||||
|
||||
$guards = $options['guards'] ?? null;
|
||||
|
||||
if (is_null($guards)) {
|
||||
return $request->user();
|
||||
}
|
||||
|
||||
foreach (Arr::wrap($guards) as $guard) {
|
||||
if ($user = $request->user($guard)) {
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve options for a certain channel.
|
||||
*
|
||||
* @param string $channel
|
||||
* @return array
|
||||
*/
|
||||
protected function retrieveChannelOptions($channel)
|
||||
{
|
||||
foreach ($this->channelOptions as $pattern => $options) {
|
||||
if (! $this->channelNameMatchesPattern($channel, $pattern)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if channel name from request match a pattern from registered channels.
|
||||
*
|
||||
* @param string $channel
|
||||
* @param string $pattern
|
||||
* @return bool
|
||||
*/
|
||||
protected function channelNameMatchesPattern($channel, $pattern)
|
||||
{
|
||||
return Str::is(preg_replace('/\{(.*?)\}/', '*', $pattern), $channel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
class PusherBroadcaster extends Broadcaster
|
||||
{
|
||||
use UsePusherChannelConventions;
|
||||
|
||||
/**
|
||||
* The Pusher SDK instance.
|
||||
*
|
||||
@@ -38,15 +40,13 @@ class PusherBroadcaster extends Broadcaster
|
||||
*/
|
||||
public function auth($request)
|
||||
{
|
||||
if (Str::startsWith($request->channel_name, ['private-', 'presence-']) &&
|
||||
! $request->user()) {
|
||||
$channelName = $this->normalizeChannelName($request->channel_name);
|
||||
|
||||
if ($this->isGuardedChannel($request->channel_name) &&
|
||||
! $this->retrieveUser($request, $channelName)) {
|
||||
throw new AccessDeniedHttpException;
|
||||
}
|
||||
|
||||
$channelName = Str::startsWith($request->channel_name, 'private-')
|
||||
? Str::replaceFirst('private-', '', $request->channel_name)
|
||||
: Str::replaceFirst('presence-', '', $request->channel_name);
|
||||
|
||||
return parent::verifyUserCanAccessChannel(
|
||||
$request, $channelName
|
||||
);
|
||||
@@ -67,11 +67,13 @@ class PusherBroadcaster extends Broadcaster
|
||||
);
|
||||
}
|
||||
|
||||
$channelName = $this->normalizeChannelName($request->channel_name);
|
||||
|
||||
return $this->decodePusherResponse(
|
||||
$request,
|
||||
$this->pusher->presence_auth(
|
||||
$request->channel_name, $request->socket_id,
|
||||
$request->user()->getAuthIdentifier(), $result
|
||||
$this->retrieveUser($request, $channelName)->getAuthIdentifier(), $result
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
namespace Illuminate\Broadcasting\Broadcasters;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Contracts\Redis\Factory as Redis;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
class RedisBroadcaster extends Broadcaster
|
||||
{
|
||||
use UsePusherChannelConventions;
|
||||
|
||||
/**
|
||||
* The Redis instance.
|
||||
*
|
||||
@@ -46,15 +47,13 @@ class RedisBroadcaster extends Broadcaster
|
||||
*/
|
||||
public function auth($request)
|
||||
{
|
||||
if (Str::startsWith($request->channel_name, ['private-', 'presence-']) &&
|
||||
! $request->user()) {
|
||||
$channelName = $this->normalizeChannelName($request->channel_name);
|
||||
|
||||
if ($this->isGuardedChannel($request->channel_name) &&
|
||||
! $this->retrieveUser($request, $channelName)) {
|
||||
throw new AccessDeniedHttpException;
|
||||
}
|
||||
|
||||
$channelName = Str::startsWith($request->channel_name, 'private-')
|
||||
? Str::replaceFirst('private-', '', $request->channel_name)
|
||||
: Str::replaceFirst('presence-', '', $request->channel_name);
|
||||
|
||||
return parent::verifyUserCanAccessChannel(
|
||||
$request, $channelName
|
||||
);
|
||||
@@ -73,8 +72,10 @@ class RedisBroadcaster extends Broadcaster
|
||||
return json_encode($result);
|
||||
}
|
||||
|
||||
$channelName = $this->normalizeChannelName($request->channel_name);
|
||||
|
||||
return json_encode(['channel_data' => [
|
||||
'user_id' => $request->user()->getAuthIdentifier(),
|
||||
'user_id' => $this->retrieveUser($request, $channelName)->getAuthIdentifier(),
|
||||
'user_info' => $result,
|
||||
]]);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Broadcasting\Broadcasters;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
trait UsePusherChannelConventions
|
||||
{
|
||||
/**
|
||||
* Return true if channel is protected by authentication.
|
||||
*
|
||||
* @param string $channel
|
||||
* @return bool
|
||||
*/
|
||||
public function isGuardedChannel($channel)
|
||||
{
|
||||
return Str::startsWith($channel, ['private-', 'presence-']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove prefix from channel name.
|
||||
*
|
||||
* @param string $channel
|
||||
* @return string
|
||||
*/
|
||||
public function normalizeChannelName($channel)
|
||||
{
|
||||
if ($this->isGuardedChannel($channel)) {
|
||||
return Str::startsWith($channel, 'private-')
|
||||
? Str::replaceFirst('private-', '', $channel)
|
||||
: Str::replaceFirst('presence-', '', $channel);
|
||||
}
|
||||
|
||||
return $channel;
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,12 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"ext-json": "*",
|
||||
"psr/log": "^1.0",
|
||||
"illuminate/bus": "5.7.*",
|
||||
"illuminate/contracts": "5.7.*",
|
||||
"illuminate/queue": "5.7.*",
|
||||
"illuminate/support": "5.7.*"
|
||||
"illuminate/bus": "5.8.*",
|
||||
"illuminate/contracts": "5.8.*",
|
||||
"illuminate/queue": "5.8.*",
|
||||
"illuminate/support": "5.8.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -28,7 +29,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.7-dev"
|
||||
"dev-master": "5.8-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
|
||||
@@ -3,19 +3,13 @@
|
||||
namespace Illuminate\Bus;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Contracts\Support\DeferrableProvider;
|
||||
use Illuminate\Contracts\Bus\Dispatcher as DispatcherContract;
|
||||
use Illuminate\Contracts\Queue\Factory as QueueFactoryContract;
|
||||
use Illuminate\Contracts\Bus\QueueingDispatcher as QueueingDispatcherContract;
|
||||
|
||||
class BusServiceProvider extends ServiceProvider
|
||||
class BusServiceProvider extends ServiceProvider implements DeferrableProvider
|
||||
{
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $defer = true;
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"illuminate/contracts": "5.7.*",
|
||||
"illuminate/pipeline": "5.7.*",
|
||||
"illuminate/support": "5.7.*"
|
||||
"illuminate/contracts": "5.8.*",
|
||||
"illuminate/pipeline": "5.8.*",
|
||||
"illuminate/support": "5.8.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -26,7 +26,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.7-dev"
|
||||
"dev-master": "5.8-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
||||
18
vendor/laravel/framework/src/Illuminate/Cache/ApcStore.php
vendored
Normal file → Executable file
18
vendor/laravel/framework/src/Illuminate/Cache/ApcStore.php
vendored
Normal file → Executable file
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
use Illuminate\Contracts\Cache\Store;
|
||||
|
||||
class ApcStore extends TaggableStore implements Store
|
||||
class ApcStore extends TaggableStore
|
||||
{
|
||||
use RetrievesMultipleKeys;
|
||||
|
||||
@@ -51,16 +49,16 @@ class ApcStore extends TaggableStore implements Store
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache for a given number of minutes.
|
||||
* Store an item in the cache for a given number of seconds.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param float|int $minutes
|
||||
* @return void
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function put($key, $value, $minutes)
|
||||
public function put($key, $value, $seconds)
|
||||
{
|
||||
$this->apc->put($this->prefix.$key, $value, (int) ($minutes * 60));
|
||||
return $this->apc->put($this->prefix.$key, $value, $seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,11 +90,11 @@ class ApcStore extends TaggableStore implements Store
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($key, $value)
|
||||
{
|
||||
$this->put($key, $value, 0);
|
||||
return $this->put($key, $value, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
0
vendor/laravel/framework/src/Illuminate/Cache/ApcWrapper.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Cache/ApcWrapper.php
vendored
Normal file → Executable file
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
use Illuminate\Contracts\Cache\Store;
|
||||
use Illuminate\Support\InteractsWithTime;
|
||||
|
||||
class ArrayStore extends TaggableStore implements Store
|
||||
class ArrayStore extends TaggableStore
|
||||
{
|
||||
use RetrievesMultipleKeys;
|
||||
use InteractsWithTime, RetrievesMultipleKeys;
|
||||
|
||||
/**
|
||||
* The array of stored values.
|
||||
@@ -23,20 +23,39 @@ class ArrayStore extends TaggableStore implements Store
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
return $this->storage[$key] ?? null;
|
||||
if (! isset($this->storage[$key])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$item = $this->storage[$key];
|
||||
|
||||
$expiresAt = $item['expiresAt'] ?? 0;
|
||||
|
||||
if ($expiresAt !== 0 && $this->currentTime() > $expiresAt) {
|
||||
$this->forget($key);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return $item['value'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache for a given number of minutes.
|
||||
* Store an item in the cache for a given number of seconds.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param float|int $minutes
|
||||
* @return void
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function put($key, $value, $minutes)
|
||||
public function put($key, $value, $seconds)
|
||||
{
|
||||
$this->storage[$key] = $value;
|
||||
$this->storage[$key] = [
|
||||
'value' => $value,
|
||||
'expiresAt' => $this->calculateExpiration($seconds),
|
||||
];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,10 +67,15 @@ class ArrayStore extends TaggableStore implements Store
|
||||
*/
|
||||
public function increment($key, $value = 1)
|
||||
{
|
||||
$this->storage[$key] = ! isset($this->storage[$key])
|
||||
? $value : ((int) $this->storage[$key]) + $value;
|
||||
if (! isset($this->storage[$key])) {
|
||||
$this->forever($key, $value);
|
||||
|
||||
return $this->storage[$key];
|
||||
return $this->storage[$key]['value'];
|
||||
}
|
||||
|
||||
$this->storage[$key]['value'] = ((int) $this->storage[$key]['value']) + $value;
|
||||
|
||||
return $this->storage[$key]['value'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,11 +95,11 @@ class ArrayStore extends TaggableStore implements Store
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($key, $value)
|
||||
{
|
||||
$this->put($key, $value, 0);
|
||||
return $this->put($key, $value, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,4 +136,26 @@ class ArrayStore extends TaggableStore implements Store
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the expiration time of the key.
|
||||
*
|
||||
* @param int $seconds
|
||||
* @return int
|
||||
*/
|
||||
protected function calculateExpiration($seconds)
|
||||
{
|
||||
return $this->toTimestamp($seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the UNIX timestamp for the given number of seconds.
|
||||
*
|
||||
* @param int $seconds
|
||||
* @return int
|
||||
*/
|
||||
protected function toTimestamp($seconds)
|
||||
{
|
||||
return $seconds > 0 ? $this->availableAt($seconds) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
57
vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php
vendored
Normal file → Executable file
57
vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php
vendored
Normal file → Executable file
@@ -3,7 +3,9 @@
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Arr;
|
||||
use InvalidArgumentException;
|
||||
use Aws\DynamoDb\DynamoDbClient;
|
||||
use Illuminate\Contracts\Cache\Store;
|
||||
use Illuminate\Contracts\Cache\Factory as FactoryContract;
|
||||
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
|
||||
@@ -16,7 +18,7 @@ class CacheManager implements FactoryContract
|
||||
/**
|
||||
* The application instance.
|
||||
*
|
||||
* @var \Illuminate\Foundation\Application
|
||||
* @var \Illuminate\Contracts\Foundation\Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
@@ -37,7 +39,7 @@ class CacheManager implements FactoryContract
|
||||
/**
|
||||
* Create a new Cache manager instance.
|
||||
*
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($app)
|
||||
@@ -46,7 +48,7 @@ class CacheManager implements FactoryContract
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a cache store instance by name.
|
||||
* Get a cache store instance by name, wrapped in a repository.
|
||||
*
|
||||
* @param string|null $name
|
||||
* @return \Illuminate\Contracts\Cache\Repository
|
||||
@@ -124,7 +126,7 @@ class CacheManager implements FactoryContract
|
||||
* Create an instance of the APC cache driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Cache\ApcStore
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function createApcDriver(array $config)
|
||||
{
|
||||
@@ -136,7 +138,7 @@ class CacheManager implements FactoryContract
|
||||
/**
|
||||
* Create an instance of the array cache driver.
|
||||
*
|
||||
* @return \Illuminate\Cache\ArrayStore
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function createArrayDriver()
|
||||
{
|
||||
@@ -147,7 +149,7 @@ class CacheManager implements FactoryContract
|
||||
* Create an instance of the file cache driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Cache\FileStore
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function createFileDriver(array $config)
|
||||
{
|
||||
@@ -158,7 +160,7 @@ class CacheManager implements FactoryContract
|
||||
* Create an instance of the Memcached cache driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Cache\MemcachedStore
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function createMemcachedDriver(array $config)
|
||||
{
|
||||
@@ -177,7 +179,7 @@ class CacheManager implements FactoryContract
|
||||
/**
|
||||
* Create an instance of the Null cache driver.
|
||||
*
|
||||
* @return \Illuminate\Cache\NullStore
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function createNullDriver()
|
||||
{
|
||||
@@ -188,7 +190,7 @@ class CacheManager implements FactoryContract
|
||||
* Create an instance of the Redis cache driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Cache\RedisStore
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function createRedisDriver(array $config)
|
||||
{
|
||||
@@ -203,7 +205,7 @@ class CacheManager implements FactoryContract
|
||||
* Create an instance of the database cache driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Cache\DatabaseStore
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function createDatabaseDriver(array $config)
|
||||
{
|
||||
@@ -216,6 +218,37 @@ class CacheManager implements FactoryContract
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the DynamoDB cache driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function createDynamodbDriver(array $config)
|
||||
{
|
||||
$dynamoConfig = [
|
||||
'region' => $config['region'],
|
||||
'version' => 'latest',
|
||||
];
|
||||
|
||||
if ($config['key'] && $config['secret']) {
|
||||
$dynamoConfig['credentials'] = Arr::only(
|
||||
$config, ['key', 'secret', 'token']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->repository(
|
||||
new DynamoDbStore(
|
||||
new DynamoDbClient($dynamoConfig),
|
||||
$config['table'],
|
||||
$config['attributes']['key'] ?? 'key',
|
||||
$config['attributes']['value'] ?? 'value',
|
||||
$config['attributes']['expiration'] ?? 'expires_at',
|
||||
$this->getPrefix($config)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new cache repository with the given implementation.
|
||||
*
|
||||
@@ -300,7 +333,7 @@ class CacheManager implements FactoryContract
|
||||
/**
|
||||
* Register a custom driver creator Closure.
|
||||
*
|
||||
* @param string $driver
|
||||
* @param string $driver
|
||||
* @param \Closure $callback
|
||||
* @return $this
|
||||
*/
|
||||
@@ -315,7 +348,7 @@ class CacheManager implements FactoryContract
|
||||
* Dynamically call the default driver instance.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
|
||||
10
vendor/laravel/framework/src/Illuminate/Cache/CacheServiceProvider.php
vendored
Normal file → Executable file
10
vendor/laravel/framework/src/Illuminate/Cache/CacheServiceProvider.php
vendored
Normal file → Executable file
@@ -3,16 +3,10 @@
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Contracts\Support\DeferrableProvider;
|
||||
|
||||
class CacheServiceProvider extends ServiceProvider
|
||||
class CacheServiceProvider extends ServiceProvider implements DeferrableProvider
|
||||
{
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $defer = true;
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
|
||||
0
vendor/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Cache/Console/ForgetCommand.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Cache/Console/ForgetCommand.php
vendored
Normal file → Executable file
20
vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php
vendored
Normal file → Executable file
20
vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php
vendored
Normal file → Executable file
@@ -84,25 +84,27 @@ class DatabaseStore implements Store
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache for a given number of minutes.
|
||||
* Store an item in the cache for a given number of seconds.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param float|int $minutes
|
||||
* @return void
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function put($key, $value, $minutes)
|
||||
public function put($key, $value, $seconds)
|
||||
{
|
||||
$key = $this->prefix.$key;
|
||||
|
||||
$value = $this->serialize($value);
|
||||
|
||||
$expiration = $this->getTime() + (int) ($minutes * 60);
|
||||
$expiration = $this->getTime() + $seconds;
|
||||
|
||||
try {
|
||||
$this->table()->insert(compact('key', 'value', 'expiration'));
|
||||
return $this->table()->insert(compact('key', 'value', 'expiration'));
|
||||
} catch (Exception $e) {
|
||||
$this->table()->where('key', $key)->update(compact('value', 'expiration'));
|
||||
$result = $this->table()->where('key', $key)->update(compact('value', 'expiration'));
|
||||
|
||||
return $result > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,11 +198,11 @@ class DatabaseStore implements Store
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($key, $value)
|
||||
{
|
||||
$this->put($key, $value, 5256000);
|
||||
return $this->put($key, $value, 315360000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
73
vendor/laravel/framework/src/Illuminate/Cache/DynamoDbLock.php
vendored
Normal file
73
vendor/laravel/framework/src/Illuminate/Cache/DynamoDbLock.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
class DynamoDbLock extends Lock
|
||||
{
|
||||
/**
|
||||
* The DynamoDB client instance.
|
||||
*
|
||||
* @var \Illuminate\Cache\DynamoDbStore
|
||||
*/
|
||||
protected $dynamo;
|
||||
|
||||
/**
|
||||
* Create a new lock instance.
|
||||
*
|
||||
* @param \Illuminate\Cache\DynamoDbStore $dynamo
|
||||
* @param string $name
|
||||
* @param int $seconds
|
||||
* @param string|null $owner
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DynamoDbStore $dynamo, $name, $seconds, $owner = null)
|
||||
{
|
||||
parent::__construct($name, $seconds, $owner);
|
||||
|
||||
$this->dynamo = $dynamo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to acquire the lock.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function acquire()
|
||||
{
|
||||
return $this->dynamo->add(
|
||||
$this->name, $this->owner, $this->seconds
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the lock.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function release()
|
||||
{
|
||||
if ($this->isOwnedByCurrentProcess()) {
|
||||
$this->dynamo->forget($this->name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Release this lock in disregard of ownership.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function forceRelease()
|
||||
{
|
||||
$this->dynamo->forget($this->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the owner value written into the driver for this lock.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getCurrentOwner()
|
||||
{
|
||||
return $this->dynamo->get($this->name);
|
||||
}
|
||||
}
|
||||
525
vendor/laravel/framework/src/Illuminate/Cache/DynamoDbStore.php
vendored
Normal file
525
vendor/laravel/framework/src/Illuminate/Cache/DynamoDbStore.php
vendored
Normal file
@@ -0,0 +1,525 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
use RuntimeException;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Aws\DynamoDb\DynamoDbClient;
|
||||
use Illuminate\Contracts\Cache\Store;
|
||||
use Illuminate\Support\InteractsWithTime;
|
||||
use Illuminate\Contracts\Cache\LockProvider;
|
||||
use Aws\DynamoDb\Exception\DynamoDbException;
|
||||
|
||||
class DynamoDbStore implements Store, LockProvider
|
||||
{
|
||||
use InteractsWithTime;
|
||||
|
||||
/**
|
||||
* The DynamoDB client instance.
|
||||
*
|
||||
* @var \Aws\DynamoDb\DynamoDbClient
|
||||
*/
|
||||
protected $dynamo;
|
||||
|
||||
/**
|
||||
* The table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table;
|
||||
|
||||
/**
|
||||
* The name of the attribute that should hold the key.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $keyAttribute;
|
||||
|
||||
/**
|
||||
* The name of the attribute that should hold the value.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $valueAttribute;
|
||||
|
||||
/**
|
||||
* The name of the attribute that should hold the expiration timestamp.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $expirationAttribute;
|
||||
|
||||
/**
|
||||
* A string that should be prepended to keys.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $prefix;
|
||||
|
||||
/**
|
||||
* Create a new store instance.
|
||||
*
|
||||
* @param \Aws\DynamoDb\DynamoDbClient $dynamo
|
||||
* @param string $table
|
||||
* @param string $keyAttribute
|
||||
* @param string $valueAttribute
|
||||
* @param string $expirationAttribute
|
||||
* @param string $prefix
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DynamoDbClient $dynamo,
|
||||
$table,
|
||||
$keyAttribute = 'key',
|
||||
$valueAttribute = 'value',
|
||||
$expirationAttribute = 'expires_at',
|
||||
$prefix = '')
|
||||
{
|
||||
$this->table = $table;
|
||||
$this->dynamo = $dynamo;
|
||||
$this->keyAttribute = $keyAttribute;
|
||||
$this->valueAttribute = $valueAttribute;
|
||||
$this->expirationAttribute = $expirationAttribute;
|
||||
|
||||
$this->setPrefix($prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an item from the cache by key.
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
$response = $this->dynamo->getItem([
|
||||
'TableName' => $this->table,
|
||||
'ConsistentRead' => false,
|
||||
'Key' => [
|
||||
$this->keyAttribute => [
|
||||
'S' => $this->prefix.$key,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
if (! isset($response['Item'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->isExpired($response['Item'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($response['Item'][$this->valueAttribute])) {
|
||||
return $this->unserialize(
|
||||
$response['Item'][$this->valueAttribute]['S'] ??
|
||||
$response['Item'][$this->valueAttribute]['N'] ??
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve multiple items from the cache by key.
|
||||
*
|
||||
* Items not found in the cache will have a null value.
|
||||
*
|
||||
* @param array $keys
|
||||
* @return array
|
||||
*/
|
||||
public function many(array $keys)
|
||||
{
|
||||
$prefixedKeys = array_map(function ($key) {
|
||||
return $this->prefix.$key;
|
||||
}, $keys);
|
||||
|
||||
$response = $this->dynamo->batchGetItem([
|
||||
'RequestItems' => [
|
||||
$this->table => [
|
||||
'ConsistentRead' => false,
|
||||
'Keys' => collect($prefixedKeys)->map(function ($key) {
|
||||
return [
|
||||
$this->keyAttribute => [
|
||||
'S' => $key,
|
||||
],
|
||||
];
|
||||
})->all(),
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$now = Carbon::now();
|
||||
|
||||
return array_merge(collect(array_flip($keys))->map(function () {
|
||||
})->all(), collect($response['Responses'][$this->table])->mapWithKeys(function ($response) use ($now) {
|
||||
if ($this->isExpired($response, $now)) {
|
||||
$value = null;
|
||||
} else {
|
||||
$value = $this->unserialize(
|
||||
$response[$this->valueAttribute]['S'] ??
|
||||
$response[$this->valueAttribute]['N'] ??
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
return [Str::replaceFirst($this->prefix, '', $response[$this->keyAttribute]['S']) => $value];
|
||||
})->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given item is expired.
|
||||
*
|
||||
* @param array $item
|
||||
* @param \DateTimeInterface|null $expiration
|
||||
* @return bool
|
||||
*/
|
||||
protected function isExpired(array $item, $expiration = null)
|
||||
{
|
||||
$expiration = $expiration ?: Carbon::now();
|
||||
|
||||
return isset($item[$this->expirationAttribute]) &&
|
||||
$expiration->getTimestamp() >= $item[$this->expirationAttribute]['N'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache for a given number of seconds.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function put($key, $value, $seconds)
|
||||
{
|
||||
$this->dynamo->putItem([
|
||||
'TableName' => $this->table,
|
||||
'Item' => [
|
||||
$this->keyAttribute => [
|
||||
'S' => $this->prefix.$key,
|
||||
],
|
||||
$this->valueAttribute => [
|
||||
$this->type($value) => $this->serialize($value),
|
||||
],
|
||||
$this->expirationAttribute => [
|
||||
'N' => (string) $this->toTimestamp($seconds),
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store multiple items in the cache for a given number of $seconds.
|
||||
*
|
||||
* @param array $values
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function putMany(array $values, $seconds)
|
||||
{
|
||||
$expiration = $this->toTimestamp($seconds);
|
||||
|
||||
$this->dynamo->batchWriteItem([
|
||||
'RequestItems' => [
|
||||
$this->table => collect($values)->map(function ($value, $key) use ($expiration) {
|
||||
return [
|
||||
'PutRequest' => [
|
||||
'Item' => [
|
||||
$this->keyAttribute => [
|
||||
'S' => $this->prefix.$key,
|
||||
],
|
||||
$this->valueAttribute => [
|
||||
$this->type($value) => $this->serialize($value),
|
||||
],
|
||||
$this->expirationAttribute => [
|
||||
'N' => (string) $expiration,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
})->values()->all(),
|
||||
],
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache if the key doesn't exist.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function add($key, $value, $seconds)
|
||||
{
|
||||
try {
|
||||
$this->dynamo->putItem([
|
||||
'TableName' => $this->table,
|
||||
'Item' => [
|
||||
$this->keyAttribute => [
|
||||
'S' => $this->prefix.$key,
|
||||
],
|
||||
$this->valueAttribute => [
|
||||
$this->type($value) => $this->serialize($value),
|
||||
],
|
||||
$this->expirationAttribute => [
|
||||
'N' => (string) $this->toTimestamp($seconds),
|
||||
],
|
||||
],
|
||||
'ConditionExpression' => 'attribute_not_exists(#key) OR #expires_at < :now',
|
||||
'ExpressionAttributeNames' => [
|
||||
'#key' => $this->keyAttribute,
|
||||
'#expires_at' => $this->expirationAttribute,
|
||||
],
|
||||
'ExpressionAttributeValues' => [
|
||||
':now' => [
|
||||
'N' => (string) Carbon::now()->getTimestamp(),
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
return true;
|
||||
} catch (DynamoDbException $e) {
|
||||
if (Str::contains($e->getMessage(), 'ConditionalCheckFailed')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the value of an item in the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int|bool
|
||||
*/
|
||||
public function increment($key, $value = 1)
|
||||
{
|
||||
try {
|
||||
$response = $this->dynamo->updateItem([
|
||||
'TableName' => $this->table,
|
||||
'Key' => [
|
||||
$this->keyAttribute => [
|
||||
'S' => $this->prefix.$key,
|
||||
],
|
||||
],
|
||||
'ConditionExpression' => 'attribute_exists(#key) AND #expires_at > :now',
|
||||
'UpdateExpression' => 'SET #value = #value + :amount',
|
||||
'ExpressionAttributeNames' => [
|
||||
'#key' => $this->keyAttribute,
|
||||
'#value' => $this->valueAttribute,
|
||||
'#expires_at' => $this->expirationAttribute,
|
||||
],
|
||||
'ExpressionAttributeValues' => [
|
||||
':now' => [
|
||||
'N' => (string) Carbon::now()->getTimestamp(),
|
||||
],
|
||||
':amount' => [
|
||||
'N' => (string) $value,
|
||||
],
|
||||
],
|
||||
'ReturnValues' => 'UPDATED_NEW',
|
||||
]);
|
||||
|
||||
return (int) $response['Attributes'][$this->valueAttribute]['N'];
|
||||
} catch (DynamoDbException $e) {
|
||||
if (Str::contains($e->getMessage(), 'ConditionalCheckFailed')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrement the value of an item in the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int|bool
|
||||
*/
|
||||
public function decrement($key, $value = 1)
|
||||
{
|
||||
try {
|
||||
$response = $this->dynamo->updateItem([
|
||||
'TableName' => $this->table,
|
||||
'Key' => [
|
||||
$this->keyAttribute => [
|
||||
'S' => $this->prefix.$key,
|
||||
],
|
||||
],
|
||||
'ConditionExpression' => 'attribute_exists(#key) AND #expires_at > :now',
|
||||
'UpdateExpression' => 'SET #value = #value - :amount',
|
||||
'ExpressionAttributeNames' => [
|
||||
'#key' => $this->keyAttribute,
|
||||
'#value' => $this->valueAttribute,
|
||||
'#expires_at' => $this->expirationAttribute,
|
||||
],
|
||||
'ExpressionAttributeValues' => [
|
||||
':now' => [
|
||||
'N' => (string) Carbon::now()->getTimestamp(),
|
||||
],
|
||||
':amount' => [
|
||||
'N' => (string) $value,
|
||||
],
|
||||
],
|
||||
'ReturnValues' => 'UPDATED_NEW',
|
||||
]);
|
||||
|
||||
return (int) $response['Attributes'][$this->valueAttribute]['N'];
|
||||
} catch (DynamoDbException $e) {
|
||||
if (Str::contains($e->getMessage(), 'ConditionalCheckFailed')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache indefinitely.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($key, $value)
|
||||
{
|
||||
return $this->put($key, $value, now()->addYears(5));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a lock instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $seconds
|
||||
* @param string|null $owner
|
||||
* @return \Illuminate\Contracts\Cache\Lock
|
||||
*/
|
||||
public function lock($name, $seconds = 0, $owner = null)
|
||||
{
|
||||
return new DynamoDbLock($this, $this->prefix.$name, $seconds, $owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore a lock instance using the owner identifier.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $owner
|
||||
* @return \Illuminate\Contracts\Cache\Lock
|
||||
*/
|
||||
public function restoreLock($name, $owner)
|
||||
{
|
||||
return $this->lock($name, 0, $owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an item from the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function forget($key)
|
||||
{
|
||||
$this->dynamo->deleteItem([
|
||||
'TableName' => $this->table,
|
||||
'Key' => [
|
||||
$this->keyAttribute => [
|
||||
'S' => $this->prefix.$key,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all items from the cache.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
throw new RuntimeException('DynamoDb does not support flushing an entire table. Please create a new table.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the UNIX timestamp for the given number of seconds.
|
||||
*
|
||||
* @param int $seconds
|
||||
* @return int
|
||||
*/
|
||||
protected function toTimestamp($seconds)
|
||||
{
|
||||
return $seconds > 0
|
||||
? $this->availableAt($seconds)
|
||||
: Carbon::now()->getTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the value.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
protected function serialize($value)
|
||||
{
|
||||
return is_numeric($value) ? (string) $value : serialize($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unserialize the value.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
protected function unserialize($value)
|
||||
{
|
||||
if (filter_var($value, FILTER_VALIDATE_INT) !== false) {
|
||||
return (int) $value;
|
||||
}
|
||||
|
||||
if (is_numeric($value)) {
|
||||
return (float) $value;
|
||||
}
|
||||
|
||||
return unserialize($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DynamoDB type for the given value.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
protected function type($value)
|
||||
{
|
||||
return is_numeric($value) ? 'N' : 'S';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cache key prefix.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPrefix()
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cache key prefix.
|
||||
*
|
||||
* @param string $prefix
|
||||
* @return void
|
||||
*/
|
||||
public function setPrefix($prefix)
|
||||
{
|
||||
$this->prefix = ! empty($prefix) ? $prefix.':' : '';
|
||||
}
|
||||
}
|
||||
@@ -12,26 +12,26 @@ class KeyWritten extends CacheEvent
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* The number of minutes the key should be valid.
|
||||
* The number of seconds the key should be valid.
|
||||
*
|
||||
* @var int
|
||||
* @var int|null
|
||||
*/
|
||||
public $minutes;
|
||||
public $seconds;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $minutes
|
||||
* @param int|null $seconds
|
||||
* @param array $tags
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($key, $value, $minutes, $tags = [])
|
||||
public function __construct($key, $value, $seconds = null, $tags = [])
|
||||
{
|
||||
parent::__construct($key, $tags);
|
||||
|
||||
$this->value = $value;
|
||||
$this->minutes = $minutes;
|
||||
$this->seconds = $seconds;
|
||||
}
|
||||
}
|
||||
|
||||
32
vendor/laravel/framework/src/Illuminate/Cache/FileStore.php
vendored
Normal file → Executable file
32
vendor/laravel/framework/src/Illuminate/Cache/FileStore.php
vendored
Normal file → Executable file
@@ -50,20 +50,22 @@ class FileStore implements Store
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache for a given number of minutes.
|
||||
* Store an item in the cache for a given number of seconds.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param float|int $minutes
|
||||
* @return void
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function put($key, $value, $minutes)
|
||||
public function put($key, $value, $seconds)
|
||||
{
|
||||
$this->ensureCacheDirectoryExists($path = $this->path($key));
|
||||
|
||||
$this->files->put(
|
||||
$path, $this->expiration($minutes).serialize($value), true
|
||||
$result = $this->files->put(
|
||||
$path, $this->expiration($seconds).serialize($value), true
|
||||
);
|
||||
|
||||
return $result !== false && $result > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,11 +114,11 @@ class FileStore implements Store
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($key, $value)
|
||||
{
|
||||
$this->put($key, $value, 0);
|
||||
return $this->put($key, $value, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,10 +188,10 @@ class FileStore implements Store
|
||||
|
||||
$data = unserialize(substr($contents, 10));
|
||||
|
||||
// Next, we'll extract the number of minutes that are remaining for a cache
|
||||
// Next, we'll extract the number of seconds that are remaining for a cache
|
||||
// so that we can properly retain the time for things like the increment
|
||||
// operation that may be performed on this cache on a later operation.
|
||||
$time = ($expire - $this->currentTime()) / 60;
|
||||
$time = $expire - $this->currentTime();
|
||||
|
||||
return compact('data', 'time');
|
||||
}
|
||||
@@ -218,16 +220,16 @@ class FileStore implements Store
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the expiration time based on the given minutes.
|
||||
* Get the expiration time based on the given seconds.
|
||||
*
|
||||
* @param float|int $minutes
|
||||
* @param int $seconds
|
||||
* @return int
|
||||
*/
|
||||
protected function expiration($minutes)
|
||||
protected function expiration($seconds)
|
||||
{
|
||||
$time = $this->availableAt((int) ($minutes * 60));
|
||||
$time = $this->availableAt($seconds);
|
||||
|
||||
return $minutes === 0 || $time > 9999999999 ? 9999999999 : (int) $time;
|
||||
return $seconds === 0 || $time > 9999999999 ? 9999999999 : $time;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\InteractsWithTime;
|
||||
use Illuminate\Contracts\Cache\Lock as LockContract;
|
||||
use Illuminate\Contracts\Cache\LockTimeoutException;
|
||||
@@ -24,16 +25,29 @@ abstract class Lock implements LockContract
|
||||
*/
|
||||
protected $seconds;
|
||||
|
||||
/**
|
||||
* The scope identifier of this lock.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $owner;
|
||||
|
||||
/**
|
||||
* Create a new lock instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $seconds
|
||||
* @param string|null $owner
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name, $seconds)
|
||||
public function __construct($name, $seconds, $owner = null)
|
||||
{
|
||||
if (is_null($owner)) {
|
||||
$owner = Str::random();
|
||||
}
|
||||
|
||||
$this->name = $name;
|
||||
$this->owner = $owner;
|
||||
$this->seconds = $seconds;
|
||||
}
|
||||
|
||||
@@ -51,20 +65,29 @@ abstract class Lock implements LockContract
|
||||
*/
|
||||
abstract public function release();
|
||||
|
||||
/**
|
||||
* Returns the owner value written into the driver for this lock.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getCurrentOwner();
|
||||
|
||||
/**
|
||||
* Attempt to acquire the lock.
|
||||
*
|
||||
* @param callable|null $callback
|
||||
* @return bool
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($callback = null)
|
||||
{
|
||||
$result = $this->acquire();
|
||||
|
||||
if ($result && is_callable($callback)) {
|
||||
return tap($callback(), function () {
|
||||
try {
|
||||
return $callback();
|
||||
} finally {
|
||||
$this->release();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -92,11 +115,33 @@ abstract class Lock implements LockContract
|
||||
}
|
||||
|
||||
if (is_callable($callback)) {
|
||||
return tap($callback(), function () {
|
||||
try {
|
||||
return $callback();
|
||||
} finally {
|
||||
$this->release();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current owner of the lock.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function owner()
|
||||
{
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether this lock is allowed to release the lock in the driver.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isOwnedByCurrentProcess()
|
||||
{
|
||||
return $this->getCurrentOwner() === $this->owner;
|
||||
}
|
||||
}
|
||||
|
||||
25
vendor/laravel/framework/src/Illuminate/Cache/LuaScripts.php
vendored
Normal file
25
vendor/laravel/framework/src/Illuminate/Cache/LuaScripts.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
class LuaScripts
|
||||
{
|
||||
/**
|
||||
* Get the Lua script to atomically release a lock.
|
||||
*
|
||||
* KEYS[1] - The name of the lock
|
||||
* ARGV[1] - The owner key of the lock instance trying to release it
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function releaseLock()
|
||||
{
|
||||
return <<<'LUA'
|
||||
if redis.call("get",KEYS[1]) == ARGV[1] then
|
||||
return redis.call("del",KEYS[1])
|
||||
else
|
||||
return 0
|
||||
end
|
||||
LUA;
|
||||
}
|
||||
}
|
||||
0
vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php
vendored
Normal file → Executable file
@@ -17,11 +17,12 @@ class MemcachedLock extends Lock
|
||||
* @param \Memcached $memcached
|
||||
* @param string $name
|
||||
* @param int $seconds
|
||||
* @param string|null $owner
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($memcached, $name, $seconds)
|
||||
public function __construct($memcached, $name, $seconds, $owner = null)
|
||||
{
|
||||
parent::__construct($name, $seconds);
|
||||
parent::__construct($name, $seconds, $owner);
|
||||
|
||||
$this->memcached = $memcached;
|
||||
}
|
||||
@@ -34,7 +35,7 @@ class MemcachedLock extends Lock
|
||||
public function acquire()
|
||||
{
|
||||
return $this->memcached->add(
|
||||
$this->name, 1, $this->seconds
|
||||
$this->name, $this->owner, $this->seconds
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,7 +45,29 @@ class MemcachedLock extends Lock
|
||||
* @return void
|
||||
*/
|
||||
public function release()
|
||||
{
|
||||
if ($this->isOwnedByCurrentProcess()) {
|
||||
$this->memcached->delete($this->name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases this lock in disregard of ownership.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function forceRelease()
|
||||
{
|
||||
$this->memcached->delete($this->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the owner value written into the driver for this lock.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getCurrentOwner()
|
||||
{
|
||||
return $this->memcached->get($this->name);
|
||||
}
|
||||
}
|
||||
|
||||
79
vendor/laravel/framework/src/Illuminate/Cache/MemcachedStore.php
vendored
Normal file → Executable file
79
vendor/laravel/framework/src/Illuminate/Cache/MemcachedStore.php
vendored
Normal file → Executable file
@@ -4,21 +4,13 @@ namespace Illuminate\Cache;
|
||||
|
||||
use Memcached;
|
||||
use ReflectionMethod;
|
||||
use Illuminate\Contracts\Cache\Store;
|
||||
use Illuminate\Support\InteractsWithTime;
|
||||
use Illuminate\Contracts\Cache\LockProvider;
|
||||
|
||||
class MemcachedStore extends TaggableStore implements LockProvider, Store
|
||||
class MemcachedStore extends TaggableStore implements LockProvider
|
||||
{
|
||||
use InteractsWithTime;
|
||||
|
||||
/**
|
||||
* The maximum value that can be specified as an expiration delta.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const REALTIME_MAXDELTA_IN_MINUTES = 43200;
|
||||
|
||||
/**
|
||||
* The Memcached instance.
|
||||
*
|
||||
@@ -101,28 +93,28 @@ class MemcachedStore extends TaggableStore implements LockProvider, Store
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache for a given number of minutes.
|
||||
* Store an item in the cache for a given number of seconds.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param float|int $minutes
|
||||
* @return void
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function put($key, $value, $minutes)
|
||||
public function put($key, $value, $seconds)
|
||||
{
|
||||
$this->memcached->set(
|
||||
$this->prefix.$key, $value, $this->calculateExpiration($minutes)
|
||||
return $this->memcached->set(
|
||||
$this->prefix.$key, $value, $this->calculateExpiration($seconds)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store multiple items in the cache for a given number of minutes.
|
||||
* Store multiple items in the cache for a given number of seconds.
|
||||
*
|
||||
* @param array $values
|
||||
* @param float|int $minutes
|
||||
* @return void
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function putMany(array $values, $minutes)
|
||||
public function putMany(array $values, $seconds)
|
||||
{
|
||||
$prefixedValues = [];
|
||||
|
||||
@@ -130,8 +122,8 @@ class MemcachedStore extends TaggableStore implements LockProvider, Store
|
||||
$prefixedValues[$this->prefix.$key] = $value;
|
||||
}
|
||||
|
||||
$this->memcached->setMulti(
|
||||
$prefixedValues, $this->calculateExpiration($minutes)
|
||||
return $this->memcached->setMulti(
|
||||
$prefixedValues, $this->calculateExpiration($seconds)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -140,13 +132,13 @@ class MemcachedStore extends TaggableStore implements LockProvider, Store
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param float|int $minutes
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function add($key, $value, $minutes)
|
||||
public function add($key, $value, $seconds)
|
||||
{
|
||||
return $this->memcached->add(
|
||||
$this->prefix.$key, $value, $this->calculateExpiration($minutes)
|
||||
$this->prefix.$key, $value, $this->calculateExpiration($seconds)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -179,23 +171,36 @@ class MemcachedStore extends TaggableStore implements LockProvider, Store
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($key, $value)
|
||||
{
|
||||
$this->put($key, $value, 0);
|
||||
return $this->put($key, $value, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a lock instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $seconds
|
||||
* @param string $name
|
||||
* @param int $seconds
|
||||
* @param string|null $owner
|
||||
* @return \Illuminate\Contracts\Cache\Lock
|
||||
*/
|
||||
public function lock($name, $seconds = 0)
|
||||
public function lock($name, $seconds = 0, $owner = null)
|
||||
{
|
||||
return new MemcachedLock($this->memcached, $this->prefix.$name, $seconds);
|
||||
return new MemcachedLock($this->memcached, $this->prefix.$name, $seconds, $owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore a lock instance using the owner identifier.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $owner
|
||||
* @return \Illuminate\Contracts\Cache\Lock
|
||||
*/
|
||||
public function restoreLock($name, $owner)
|
||||
{
|
||||
return $this->lock($name, 0, $owner);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,23 +227,23 @@ class MemcachedStore extends TaggableStore implements LockProvider, Store
|
||||
/**
|
||||
* Get the expiration time of the key.
|
||||
*
|
||||
* @param int $minutes
|
||||
* @param int $seconds
|
||||
* @return int
|
||||
*/
|
||||
protected function calculateExpiration($minutes)
|
||||
protected function calculateExpiration($seconds)
|
||||
{
|
||||
return $this->toTimestamp($minutes);
|
||||
return $this->toTimestamp($seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the UNIX timestamp for the given number of minutes.
|
||||
* Get the UNIX timestamp for the given number of seconds.
|
||||
*
|
||||
* @param int $minutes
|
||||
* @param int $seconds
|
||||
* @return int
|
||||
*/
|
||||
protected function toTimestamp($minutes)
|
||||
protected function toTimestamp($seconds)
|
||||
{
|
||||
return $minutes > 0 ? $this->availableAt($minutes * 60) : 0;
|
||||
return $seconds > 0 ? $this->availableAt($seconds) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
31
vendor/laravel/framework/src/Illuminate/Cache/NullStore.php
vendored
Normal file → Executable file
31
vendor/laravel/framework/src/Illuminate/Cache/NullStore.php
vendored
Normal file → Executable file
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
use Illuminate\Contracts\Cache\Store;
|
||||
|
||||
class NullStore extends TaggableStore implements Store
|
||||
class NullStore extends TaggableStore
|
||||
{
|
||||
use RetrievesMultipleKeys;
|
||||
|
||||
@@ -23,20 +21,19 @@ class NullStore extends TaggableStore implements Store
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache for a given number of minutes.
|
||||
* Store an item in the cache for a given number of seconds.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param float|int $minutes
|
||||
* @return void
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function put($key, $value, $minutes)
|
||||
public function put($key, $value, $seconds)
|
||||
{
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,11 +41,11 @@ class NullStore extends TaggableStore implements Store
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int
|
||||
* @return int|bool
|
||||
*/
|
||||
public function increment($key, $value = 1)
|
||||
{
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,11 +53,11 @@ class NullStore extends TaggableStore implements Store
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int
|
||||
* @return int|bool
|
||||
*/
|
||||
public function decrement($key, $value = 1)
|
||||
{
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,22 +65,22 @@ class NullStore extends TaggableStore implements Store
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($key, $value)
|
||||
{
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an item from the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function forget($key)
|
||||
{
|
||||
//
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,21 +51,21 @@ class RateLimiter
|
||||
* Increment the counter for a given key for a given decay time.
|
||||
*
|
||||
* @param string $key
|
||||
* @param float|int $decayMinutes
|
||||
* @param int $decaySeconds
|
||||
* @return int
|
||||
*/
|
||||
public function hit($key, $decayMinutes = 1)
|
||||
public function hit($key, $decaySeconds = 60)
|
||||
{
|
||||
$this->cache->add(
|
||||
$key.':timer', $this->availableAt($decayMinutes * 60), $decayMinutes
|
||||
$key.':timer', $this->availableAt($decaySeconds), $decaySeconds
|
||||
);
|
||||
|
||||
$added = $this->cache->add($key, 0, $decayMinutes);
|
||||
$added = $this->cache->add($key, 0, $decaySeconds);
|
||||
|
||||
$hits = (int) $this->cache->increment($key);
|
||||
|
||||
if (! $added && $hits == 1) {
|
||||
$this->cache->put($key, 1, $decayMinutes);
|
||||
$this->cache->put($key, 1, $decaySeconds);
|
||||
}
|
||||
|
||||
return $hits;
|
||||
|
||||
@@ -17,11 +17,12 @@ class RedisLock extends Lock
|
||||
* @param \Illuminate\Redis\Connections\Connection $redis
|
||||
* @param string $name
|
||||
* @param int $seconds
|
||||
* @param string|null $owner
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($redis, $name, $seconds)
|
||||
public function __construct($redis, $name, $seconds, $owner = null)
|
||||
{
|
||||
parent::__construct($name, $seconds);
|
||||
parent::__construct($name, $seconds, $owner);
|
||||
|
||||
$this->redis = $redis;
|
||||
}
|
||||
@@ -33,7 +34,7 @@ class RedisLock extends Lock
|
||||
*/
|
||||
public function acquire()
|
||||
{
|
||||
$result = $this->redis->setnx($this->name, 1);
|
||||
$result = $this->redis->setnx($this->name, $this->owner);
|
||||
|
||||
if ($result === 1 && $this->seconds > 0) {
|
||||
$this->redis->expire($this->name, $this->seconds);
|
||||
@@ -48,7 +49,27 @@ class RedisLock extends Lock
|
||||
* @return void
|
||||
*/
|
||||
public function release()
|
||||
{
|
||||
$this->redis->eval(LuaScripts::releaseLock(), 1, $this->name, $this->owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases this lock in disregard of ownership.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function forceRelease()
|
||||
{
|
||||
$this->redis->del($this->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the owner value written into the driver for this lock.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getCurrentOwner()
|
||||
{
|
||||
return $this->redis->get($this->name);
|
||||
}
|
||||
}
|
||||
|
||||
63
vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php
vendored
Normal file → Executable file
63
vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php
vendored
Normal file → Executable file
@@ -2,10 +2,10 @@
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
use Illuminate\Contracts\Cache\Store;
|
||||
use Illuminate\Contracts\Cache\LockProvider;
|
||||
use Illuminate\Contracts\Redis\Factory as Redis;
|
||||
|
||||
class RedisStore extends TaggableStore implements Store
|
||||
class RedisStore extends TaggableStore implements LockProvider
|
||||
{
|
||||
/**
|
||||
* The Redis factory implementation.
|
||||
@@ -80,36 +80,42 @@ class RedisStore extends TaggableStore implements Store
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache for a given number of minutes.
|
||||
* Store an item in the cache for a given number of seconds.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param float|int $minutes
|
||||
* @return void
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function put($key, $value, $minutes)
|
||||
public function put($key, $value, $seconds)
|
||||
{
|
||||
$this->connection()->setex(
|
||||
$this->prefix.$key, (int) max(1, $minutes * 60), $this->serialize($value)
|
||||
return (bool) $this->connection()->setex(
|
||||
$this->prefix.$key, (int) max(1, $seconds), $this->serialize($value)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store multiple items in the cache for a given number of minutes.
|
||||
* Store multiple items in the cache for a given number of seconds.
|
||||
*
|
||||
* @param array $values
|
||||
* @param float|int $minutes
|
||||
* @return void
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function putMany(array $values, $minutes)
|
||||
public function putMany(array $values, $seconds)
|
||||
{
|
||||
$this->connection()->multi();
|
||||
|
||||
$manyResult = null;
|
||||
|
||||
foreach ($values as $key => $value) {
|
||||
$this->put($key, $value, $minutes);
|
||||
$result = $this->put($key, $value, $seconds);
|
||||
|
||||
$manyResult = is_null($manyResult) ? $result : $result && $manyResult;
|
||||
}
|
||||
|
||||
$this->connection()->exec();
|
||||
|
||||
return $manyResult ?: false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,15 +123,15 @@ class RedisStore extends TaggableStore implements Store
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param float|int $minutes
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function add($key, $value, $minutes)
|
||||
public function add($key, $value, $seconds)
|
||||
{
|
||||
$lua = "return redis.call('exists',KEYS[1])<1 and redis.call('setex',KEYS[1],ARGV[2],ARGV[1])";
|
||||
|
||||
return (bool) $this->connection()->eval(
|
||||
$lua, 1, $this->prefix.$key, $this->serialize($value), (int) max(1, $minutes * 60)
|
||||
$lua, 1, $this->prefix.$key, $this->serialize($value), (int) max(1, $seconds)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -158,23 +164,36 @@ class RedisStore extends TaggableStore implements Store
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($key, $value)
|
||||
{
|
||||
$this->connection()->set($this->prefix.$key, $this->serialize($value));
|
||||
return (bool) $this->connection()->set($this->prefix.$key, $this->serialize($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a lock instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $seconds
|
||||
* @param string $name
|
||||
* @param int $seconds
|
||||
* @param string|null $owner
|
||||
* @return \Illuminate\Contracts\Cache\Lock
|
||||
*/
|
||||
public function lock($name, $seconds = 0)
|
||||
public function lock($name, $seconds = 0, $owner = null)
|
||||
{
|
||||
return new RedisLock($this->connection(), $this->prefix.$name, $seconds);
|
||||
return new RedisLock($this->connection(), $this->prefix.$name, $seconds, $owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore a lock instance using the owner identifier.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $owner
|
||||
* @return \Illuminate\Contracts\Cache\Lock
|
||||
*/
|
||||
public function restoreLock($name, $owner)
|
||||
{
|
||||
return $this->lock($name, 0, $owner);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,14 +22,18 @@ class RedisTaggedCache extends TaggedCache
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param \DateTime|float|int|null $minutes
|
||||
* @return void
|
||||
* @param \DateTimeInterface|\DateInterval|int|null $ttl
|
||||
* @return bool
|
||||
*/
|
||||
public function put($key, $value, $minutes = null)
|
||||
public function put($key, $value, $ttl = null)
|
||||
{
|
||||
if ($ttl === null) {
|
||||
return $this->forever($key, $value);
|
||||
}
|
||||
|
||||
$this->pushStandardKeys($this->tags->getNamespace(), $key);
|
||||
|
||||
parent::put($key, $value, $minutes);
|
||||
return parent::put($key, $value, $ttl);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,13 +69,13 @@ class RedisTaggedCache extends TaggedCache
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($key, $value)
|
||||
{
|
||||
$this->pushForeverKeys($this->tags->getNamespace(), $key);
|
||||
|
||||
parent::forever($key, $value);
|
||||
return parent::forever($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
181
vendor/laravel/framework/src/Illuminate/Cache/Repository.php
vendored
Normal file → Executable file
181
vendor/laravel/framework/src/Illuminate/Cache/Repository.php
vendored
Normal file → Executable file
@@ -42,11 +42,11 @@ class Repository implements CacheContract, ArrayAccess
|
||||
protected $events;
|
||||
|
||||
/**
|
||||
* The default number of minutes to store items.
|
||||
* The default number of seconds to store items.
|
||||
*
|
||||
* @var float|int
|
||||
* @var int|null
|
||||
*/
|
||||
protected $default = 60;
|
||||
protected $default = 3600;
|
||||
|
||||
/**
|
||||
* Create a new cache repository instance.
|
||||
@@ -193,22 +193,32 @@ class Repository implements CacheContract, ArrayAccess
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param \DateTimeInterface|\DateInterval|float|int|null $minutes
|
||||
* @return void
|
||||
* @param \DateTimeInterface|\DateInterval|int|null $ttl
|
||||
* @return bool
|
||||
*/
|
||||
public function put($key, $value, $minutes = null)
|
||||
public function put($key, $value, $ttl = null)
|
||||
{
|
||||
if (is_array($key)) {
|
||||
$this->putMany($key, $value);
|
||||
|
||||
return;
|
||||
return $this->putMany($key, $value);
|
||||
}
|
||||
|
||||
if (! is_null($minutes = $this->getMinutes($minutes))) {
|
||||
$this->store->put($this->itemKey($key), $value, $minutes);
|
||||
|
||||
$this->event(new KeyWritten($key, $value, $minutes));
|
||||
if ($ttl === null) {
|
||||
return $this->forever($key, $value);
|
||||
}
|
||||
|
||||
$seconds = $this->getSeconds($ttl);
|
||||
|
||||
if ($seconds <= 0) {
|
||||
return $this->delete($key);
|
||||
}
|
||||
|
||||
$result = $this->store->put($this->itemKey($key), $value, $seconds);
|
||||
|
||||
if ($result) {
|
||||
$this->event(new KeyWritten($key, $value, $seconds));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,25 +226,56 @@ class Repository implements CacheContract, ArrayAccess
|
||||
*/
|
||||
public function set($key, $value, $ttl = null)
|
||||
{
|
||||
$this->put($key, $value, $ttl);
|
||||
return $this->put($key, $value, $ttl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store multiple items in the cache for a given number of minutes.
|
||||
* Store multiple items in the cache for a given number of seconds.
|
||||
*
|
||||
* @param array $values
|
||||
* @param \DateTimeInterface|\DateInterval|float|int $minutes
|
||||
* @return void
|
||||
* @param \DateTimeInterface|\DateInterval|int|null $ttl
|
||||
* @return bool
|
||||
*/
|
||||
public function putMany(array $values, $minutes)
|
||||
public function putMany(array $values, $ttl = null)
|
||||
{
|
||||
if (! is_null($minutes = $this->getMinutes($minutes))) {
|
||||
$this->store->putMany($values, $minutes);
|
||||
if ($ttl === null) {
|
||||
return $this->putManyForever($values);
|
||||
}
|
||||
|
||||
$seconds = $this->getSeconds($ttl);
|
||||
|
||||
if ($seconds <= 0) {
|
||||
return $this->deleteMultiple(array_keys($values));
|
||||
}
|
||||
|
||||
$result = $this->store->putMany($values, $seconds);
|
||||
|
||||
if ($result) {
|
||||
foreach ($values as $key => $value) {
|
||||
$this->event(new KeyWritten($key, $value, $minutes));
|
||||
$this->event(new KeyWritten($key, $value, $seconds));
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store multiple items in the cache indefinitely.
|
||||
*
|
||||
* @param array $values
|
||||
* @return bool
|
||||
*/
|
||||
protected function putManyForever(array $values)
|
||||
{
|
||||
$result = true;
|
||||
|
||||
foreach ($values as $key => $value) {
|
||||
if (! $this->forever($key, $value)) {
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,7 +283,7 @@ class Repository implements CacheContract, ArrayAccess
|
||||
*/
|
||||
public function setMultiple($values, $ttl = null)
|
||||
{
|
||||
$this->putMany($values, $ttl);
|
||||
return $this->putMany($values, $ttl);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,31 +291,33 @@ class Repository implements CacheContract, ArrayAccess
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param \DateTimeInterface|\DateInterval|float|int $minutes
|
||||
* @param \DateTimeInterface|\DateInterval|int|null $ttl
|
||||
* @return bool
|
||||
*/
|
||||
public function add($key, $value, $minutes)
|
||||
public function add($key, $value, $ttl = null)
|
||||
{
|
||||
if (is_null($minutes = $this->getMinutes($minutes))) {
|
||||
return false;
|
||||
}
|
||||
if ($ttl !== null) {
|
||||
if ($this->getSeconds($ttl) <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the store has an "add" method we will call the method on the store so it
|
||||
// has a chance to override this logic. Some drivers better support the way
|
||||
// this operation should work with a total "atomic" implementation of it.
|
||||
if (method_exists($this->store, 'add')) {
|
||||
return $this->store->add(
|
||||
$this->itemKey($key), $value, $minutes
|
||||
);
|
||||
// If the store has an "add" method we will call the method on the store so it
|
||||
// has a chance to override this logic. Some drivers better support the way
|
||||
// this operation should work with a total "atomic" implementation of it.
|
||||
if (method_exists($this->store, 'add')) {
|
||||
$seconds = $this->getSeconds($ttl);
|
||||
|
||||
return $this->store->add(
|
||||
$this->itemKey($key), $value, $seconds
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// If the value did not exist in the cache, we will put the value in the cache
|
||||
// so it exists for subsequent requests. Then, we will return true so it is
|
||||
// easy to know if the value gets added. Otherwise, we will return false.
|
||||
if (is_null($this->get($key))) {
|
||||
$this->put($key, $value, $minutes);
|
||||
|
||||
return true;
|
||||
return $this->put($key, $value, $ttl);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -308,36 +351,40 @@ class Repository implements CacheContract, ArrayAccess
|
||||
* Store an item in the cache indefinitely.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($key, $value)
|
||||
{
|
||||
$this->store->forever($this->itemKey($key), $value);
|
||||
$result = $this->store->forever($this->itemKey($key), $value);
|
||||
|
||||
$this->event(new KeyWritten($key, $value, 0));
|
||||
if ($result) {
|
||||
$this->event(new KeyWritten($key, $value));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an item from the cache, or execute the given Closure and store the result.
|
||||
*
|
||||
* @param string $key
|
||||
* @param \DateTimeInterface|\DateInterval|float|int $minutes
|
||||
* @param \DateTimeInterface|\DateInterval|int|null $ttl
|
||||
* @param \Closure $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function remember($key, $minutes, Closure $callback)
|
||||
public function remember($key, $ttl, Closure $callback)
|
||||
{
|
||||
$value = $this->get($key);
|
||||
|
||||
// If the item exists in the cache we will just return this immediately and if
|
||||
// not we will execute the given Closure and cache the result of that for a
|
||||
// given number of minutes so it's available for all subsequent requests.
|
||||
// given number of seconds so it's available for all subsequent requests.
|
||||
if (! is_null($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$this->put($key, $value = $callback(), $minutes);
|
||||
$this->put($key, $value = $callback(), $ttl);
|
||||
|
||||
return $value;
|
||||
}
|
||||
@@ -365,9 +412,9 @@ class Repository implements CacheContract, ArrayAccess
|
||||
{
|
||||
$value = $this->get($key);
|
||||
|
||||
// If the item exists in the cache we will just return this immediately and if
|
||||
// not we will execute the given Closure and cache the result of that for a
|
||||
// given number of minutes so it's available for all subsequent requests.
|
||||
// If the item exists in the cache we will just return this immediately
|
||||
// and if not we will execute the given Closure and cache the result
|
||||
// of that forever so it is available for all subsequent requests.
|
||||
if (! is_null($value)) {
|
||||
return $value;
|
||||
}
|
||||
@@ -385,8 +432,10 @@ class Repository implements CacheContract, ArrayAccess
|
||||
*/
|
||||
public function forget($key)
|
||||
{
|
||||
return tap($this->store->forget($this->itemKey($key)), function () use ($key) {
|
||||
$this->event(new KeyForgotten($key));
|
||||
return tap($this->store->forget($this->itemKey($key)), function ($result) use ($key) {
|
||||
if ($result) {
|
||||
$this->event(new KeyForgotten($key));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -403,11 +452,15 @@ class Repository implements CacheContract, ArrayAccess
|
||||
*/
|
||||
public function deleteMultiple($keys)
|
||||
{
|
||||
$result = true;
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$this->forget($key);
|
||||
if (! $this->forget($key)) {
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -455,7 +508,7 @@ class Repository implements CacheContract, ArrayAccess
|
||||
/**
|
||||
* Get the default cache time.
|
||||
*
|
||||
* @return float|int
|
||||
* @return int
|
||||
*/
|
||||
public function getDefaultCacheTime()
|
||||
{
|
||||
@@ -463,14 +516,14 @@ class Repository implements CacheContract, ArrayAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default cache time in minutes.
|
||||
* Set the default cache time in seconds.
|
||||
*
|
||||
* @param float|int $minutes
|
||||
* @param int|null $seconds
|
||||
* @return $this
|
||||
*/
|
||||
public function setDefaultCacheTime($minutes)
|
||||
public function setDefaultCacheTime($seconds)
|
||||
{
|
||||
$this->default = $minutes;
|
||||
$this->default = $seconds;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -555,20 +608,20 @@ class Repository implements CacheContract, ArrayAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the number of minutes with the given duration.
|
||||
* Calculate the number of seconds for the given TTL.
|
||||
*
|
||||
* @param \DateTimeInterface|\DateInterval|float|int $duration
|
||||
* @return float|int|null
|
||||
* @param \DateTimeInterface|\DateInterval|int $ttl
|
||||
* @return int
|
||||
*/
|
||||
protected function getMinutes($duration)
|
||||
protected function getSeconds($ttl)
|
||||
{
|
||||
$duration = $this->parseDateInterval($duration);
|
||||
$duration = $this->parseDateInterval($ttl);
|
||||
|
||||
if ($duration instanceof DateTimeInterface) {
|
||||
$duration = Carbon::now()->diffInRealSeconds($duration, false) / 60;
|
||||
$duration = Carbon::now()->diffInRealSeconds($duration, false);
|
||||
}
|
||||
|
||||
return (int) ($duration * 60) > 0 ? $duration : null;
|
||||
return (int) $duration > 0 ? $duration : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,16 +24,22 @@ trait RetrievesMultipleKeys
|
||||
}
|
||||
|
||||
/**
|
||||
* Store multiple items in the cache for a given number of minutes.
|
||||
* Store multiple items in the cache for a given number of seconds.
|
||||
*
|
||||
* @param array $values
|
||||
* @param float|int $minutes
|
||||
* @return void
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function putMany(array $values, $minutes)
|
||||
public function putMany(array $values, $seconds)
|
||||
{
|
||||
$manyResult = null;
|
||||
|
||||
foreach ($values as $key => $value) {
|
||||
$this->put($key, $value, $minutes);
|
||||
$result = $this->put($key, $value, $seconds);
|
||||
|
||||
$manyResult = is_null($manyResult) ? $result : $result && $manyResult;
|
||||
}
|
||||
|
||||
return $manyResult ?: false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
abstract class TaggableStore
|
||||
use Illuminate\Contracts\Cache\Store;
|
||||
|
||||
abstract class TaggableStore implements Store
|
||||
{
|
||||
/**
|
||||
* Begin executing a new tags operation.
|
||||
|
||||
@@ -6,7 +6,9 @@ use Illuminate\Contracts\Cache\Store;
|
||||
|
||||
class TaggedCache extends Repository
|
||||
{
|
||||
use RetrievesMultipleKeys;
|
||||
use RetrievesMultipleKeys {
|
||||
putMany as putManyAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
* The tag set instance.
|
||||
@@ -29,6 +31,22 @@ class TaggedCache extends Repository
|
||||
$this->tags = $tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store multiple items in the cache for a given number of seconds.
|
||||
*
|
||||
* @param array $values
|
||||
* @param int|null $ttl
|
||||
* @return bool
|
||||
*/
|
||||
public function putMany(array $values, $ttl = null)
|
||||
{
|
||||
if ($ttl === null) {
|
||||
return $this->putManyForever($values);
|
||||
}
|
||||
|
||||
return $this->putManyAlias($values, $ttl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the value of an item in the cache.
|
||||
*
|
||||
@@ -94,4 +112,14 @@ class TaggedCache extends Repository
|
||||
{
|
||||
parent::event($event->setTags($this->tags->getNames()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tag set instance.
|
||||
*
|
||||
* @return \Illuminate\Cache\TagSet
|
||||
*/
|
||||
public function getTags()
|
||||
{
|
||||
return $this->tags;
|
||||
}
|
||||
}
|
||||
|
||||
12
vendor/laravel/framework/src/Illuminate/Cache/composer.json
vendored
Normal file → Executable file
12
vendor/laravel/framework/src/Illuminate/Cache/composer.json
vendored
Normal file → Executable file
@@ -15,8 +15,8 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"illuminate/contracts": "5.7.*",
|
||||
"illuminate/support": "5.7.*"
|
||||
"illuminate/contracts": "5.8.*",
|
||||
"illuminate/support": "5.8.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -25,13 +25,13 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.7-dev"
|
||||
"dev-master": "5.8-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"illuminate/database": "Required to use the database cache driver (5.7.*).",
|
||||
"illuminate/filesystem": "Required to use the file cache driver (5.7.*).",
|
||||
"illuminate/redis": "Required to use the redis cache driver (5.7.*)."
|
||||
"illuminate/database": "Required to use the database cache driver (5.8.*).",
|
||||
"illuminate/filesystem": "Required to use the file cache driver (5.8.*).",
|
||||
"illuminate/redis": "Required to use the redis cache driver (5.8.*)."
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
|
||||
6
vendor/laravel/framework/src/Illuminate/Config/composer.json
vendored
Normal file → Executable file
6
vendor/laravel/framework/src/Illuminate/Config/composer.json
vendored
Normal file → Executable file
@@ -15,8 +15,8 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"illuminate/contracts": "5.7.*",
|
||||
"illuminate/support": "5.7.*"
|
||||
"illuminate/contracts": "5.8.*",
|
||||
"illuminate/support": "5.8.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -25,7 +25,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.7-dev"
|
||||
"dev-master": "5.8-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
||||
35
vendor/laravel/framework/src/Illuminate/Console/Application.php
vendored
Normal file → Executable file
35
vendor/laravel/framework/src/Illuminate/Console/Application.php
vendored
Normal file → Executable file
@@ -9,6 +9,7 @@ use Illuminate\Contracts\Container\Container;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
use Symfony\Component\Process\PhpExecutableFinder;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
@@ -171,25 +172,41 @@ class Application extends SymfonyApplication implements ApplicationContract
|
||||
*/
|
||||
public function call($command, array $parameters = [], $outputBuffer = null)
|
||||
{
|
||||
if (is_subclass_of($command, SymfonyCommand::class)) {
|
||||
$command = $this->laravel->make($command)->getName();
|
||||
}
|
||||
[$command, $input] = $this->parseCommand($command, $parameters);
|
||||
|
||||
if (! $this->has($command)) {
|
||||
throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $command));
|
||||
}
|
||||
|
||||
array_unshift($parameters, $command);
|
||||
return $this->run(
|
||||
$input, $this->lastOutput = $outputBuffer ?: new BufferedOutput
|
||||
);
|
||||
}
|
||||
|
||||
$this->lastOutput = $outputBuffer ?: new BufferedOutput;
|
||||
/**
|
||||
* Parse the incoming Artisan command and its input.
|
||||
*
|
||||
* @param string $command
|
||||
* @param array $parameters
|
||||
* @return array
|
||||
*/
|
||||
protected function parseCommand($command, $parameters)
|
||||
{
|
||||
if (is_subclass_of($command, SymfonyCommand::class)) {
|
||||
$callingClass = true;
|
||||
|
||||
$this->setCatchExceptions(false);
|
||||
$command = $this->laravel->make($command)->getName();
|
||||
}
|
||||
|
||||
$result = $this->run(new ArrayInput($parameters), $this->lastOutput);
|
||||
if (! isset($callingClass) && empty($parameters)) {
|
||||
$command = $this->getCommandName($input = new StringInput($command));
|
||||
} else {
|
||||
array_unshift($parameters, $command);
|
||||
|
||||
$this->setCatchExceptions(true);
|
||||
$input = new ArrayInput($parameters);
|
||||
}
|
||||
|
||||
return $result;
|
||||
return [$command, $input ?? null];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
2
vendor/laravel/framework/src/Illuminate/Console/Command.php
vendored
Normal file → Executable file
2
vendor/laravel/framework/src/Illuminate/Console/Command.php
vendored
Normal file → Executable file
@@ -299,7 +299,7 @@ class Command extends SymfonyCommand
|
||||
* Get the value of a command option.
|
||||
*
|
||||
* @param string|null $key
|
||||
* @return string|array|null
|
||||
* @return string|array|bool|null
|
||||
*/
|
||||
public function option($key = null)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ class CacheEventMutex implements EventMutex
|
||||
public function create(Event $event)
|
||||
{
|
||||
return $this->cache->store($this->store)->add(
|
||||
$event->mutexName(), true, $event->expiresAt
|
||||
$event->mutexName(), true, $event->expiresAt * 60
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class CacheSchedulingMutex implements SchedulingMutex
|
||||
public function create(Event $event, DateTimeInterface $time)
|
||||
{
|
||||
return $this->cache->store($this->store)->add(
|
||||
$event->mutexName().$time->format('Hi'), true, 60
|
||||
$event->mutexName().$time->format('Hi'), true, 3600
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ use Cron\CronExpression;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Carbon;
|
||||
use GuzzleHttp\Client as HttpClient;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Illuminate\Contracts\Mail\Mailer;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
@@ -142,17 +143,27 @@ class Event
|
||||
*/
|
||||
public $mutex;
|
||||
|
||||
/**
|
||||
* The exit status code of the command.
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
public $exitCode;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\EventMutex $mutex
|
||||
* @param string $command
|
||||
* @param \DateTimeZone|string $timezone
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(EventMutex $mutex, $command)
|
||||
public function __construct(EventMutex $mutex, $command, $timezone = null)
|
||||
{
|
||||
$this->mutex = $mutex;
|
||||
$this->command = $command;
|
||||
$this->timezone = $timezone;
|
||||
|
||||
$this->output = $this->getDefaultOutput();
|
||||
}
|
||||
|
||||
@@ -204,9 +215,7 @@ class Event
|
||||
{
|
||||
$this->callBeforeCallbacks($container);
|
||||
|
||||
(new Process(
|
||||
$this->buildCommand(), base_path(), null, null, null
|
||||
))->run();
|
||||
$this->exitCode = Process::fromShellCommandline($this->buildCommand(), base_path(), null, null, null)->run();
|
||||
|
||||
$this->callAfterCallbacks($container);
|
||||
}
|
||||
@@ -221,9 +230,7 @@ class Event
|
||||
{
|
||||
$this->callBeforeCallbacks($container);
|
||||
|
||||
(new Process(
|
||||
$this->buildCommand(), base_path(), null, null, null
|
||||
))->run();
|
||||
Process::fromShellCommandline($this->buildCommand(), base_path(), null, null, null)->run();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,7 +395,7 @@ class Event
|
||||
*/
|
||||
public function emailOutputTo($addresses, $onlyIfOutputExists = false)
|
||||
{
|
||||
$this->ensureOutputIsBeingCapturedForEmail();
|
||||
$this->ensureOutputIsBeingCaptured();
|
||||
|
||||
$addresses = Arr::wrap($addresses);
|
||||
|
||||
@@ -411,15 +418,20 @@ class Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that output is being captured for email.
|
||||
* E-mail the results of the scheduled operation if it fails.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @deprecated See ensureOutputIsBeingCaptured.
|
||||
* @param array|mixed $addresses
|
||||
* @return $this
|
||||
*/
|
||||
protected function ensureOutputIsBeingCapturedForEmail()
|
||||
public function emailOutputOnFailure($addresses)
|
||||
{
|
||||
$this->ensureOutputIsBeingCaptured();
|
||||
|
||||
$addresses = Arr::wrap($addresses);
|
||||
|
||||
return $this->onFailure(function (Mailer $mailer) use ($addresses) {
|
||||
$this->emailOutput($mailer, $addresses, false);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -519,6 +531,32 @@ class Event
|
||||
return $value ? $this->thenPing($url) : $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback to ping a given URL if the operation succeeds.
|
||||
*
|
||||
* @param string $url
|
||||
* @return $this
|
||||
*/
|
||||
public function pingOnSuccess($url)
|
||||
{
|
||||
return $this->onSuccess(function () use ($url) {
|
||||
(new HttpClient)->get($url);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback to ping a given URL if the operation fails.
|
||||
*
|
||||
* @param string $url
|
||||
* @return $this
|
||||
*/
|
||||
public function pingOnFailure($url)
|
||||
{
|
||||
return $this->onFailure(function () use ($url) {
|
||||
(new HttpClient)->get($url);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* State that the command should run in background.
|
||||
*
|
||||
@@ -667,6 +705,36 @@ class Event
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback to be called if the operation succeeds.
|
||||
*
|
||||
* @param \Closure $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function onSuccess(Closure $callback)
|
||||
{
|
||||
return $this->then(function (Container $container) use ($callback) {
|
||||
if (0 === $this->exitCode) {
|
||||
$container->call($callback);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback to be called if the operation fails.
|
||||
*
|
||||
* @param \Closure $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function onFailure(Closure $callback)
|
||||
{
|
||||
return $this->then(function (Container $container) use ($callback) {
|
||||
if (0 !== $this->exitCode) {
|
||||
$container->call($callback);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the human-friendly description of the event.
|
||||
*
|
||||
@@ -708,14 +776,14 @@ class Event
|
||||
/**
|
||||
* Determine the next due date for an event.
|
||||
*
|
||||
* @param \DateTime|string $currentTime
|
||||
* @param \DateTimeInterface|string $currentTime
|
||||
* @param int $nth
|
||||
* @param bool $allowCurrentDate
|
||||
* @return \Illuminate\Support\Carbon
|
||||
*/
|
||||
public function nextRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false)
|
||||
{
|
||||
return Carbon::instance(CronExpression::factory(
|
||||
return Date::instance(CronExpression::factory(
|
||||
$this->getExpression()
|
||||
)->getNextRunDate($currentTime, $nth, $allowCurrentDate, $this->timezone));
|
||||
}
|
||||
|
||||
@@ -31,13 +31,23 @@ class Schedule
|
||||
*/
|
||||
protected $schedulingMutex;
|
||||
|
||||
/**
|
||||
* The timezone the date should be evaluated on.
|
||||
*
|
||||
* @var \DateTimeZone|string
|
||||
*/
|
||||
protected $timezone;
|
||||
|
||||
/**
|
||||
* Create a new schedule instance.
|
||||
*
|
||||
* @param \DateTimeZone|string|null $timezone
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($timezone = null)
|
||||
{
|
||||
$this->timezone = $timezone;
|
||||
|
||||
$container = Container::getInstance();
|
||||
|
||||
$this->eventMutex = $container->bound(EventMutex::class)
|
||||
@@ -119,7 +129,7 @@ class Schedule
|
||||
$command .= ' '.$this->compileParameters($parameters);
|
||||
}
|
||||
|
||||
$this->events[] = $event = new Event($this->eventMutex, $command);
|
||||
$this->events[] = $event = new Event($this->eventMutex, $command, $this->timezone);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace Illuminate\Console\Scheduling;
|
||||
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
|
||||
class ScheduleRunCommand extends Command
|
||||
{
|
||||
@@ -52,7 +52,7 @@ class ScheduleRunCommand extends Command
|
||||
{
|
||||
$this->schedule = $schedule;
|
||||
|
||||
$this->startedAt = Carbon::now();
|
||||
$this->startedAt = Date::now();
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
11
vendor/laravel/framework/src/Illuminate/Console/composer.json
vendored
Normal file → Executable file
11
vendor/laravel/framework/src/Illuminate/Console/composer.json
vendored
Normal file → Executable file
@@ -15,9 +15,10 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"illuminate/contracts": "5.7.*",
|
||||
"illuminate/support": "5.7.*",
|
||||
"symfony/console": "^4.1"
|
||||
"illuminate/contracts": "5.8.*",
|
||||
"illuminate/support": "5.8.*",
|
||||
"symfony/console": "^4.2",
|
||||
"symfony/process": "^4.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -26,13 +27,13 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.7-dev"
|
||||
"dev-master": "5.8-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"dragonmantank/cron-expression": "Required to use scheduling component (^2.0).",
|
||||
"guzzlehttp/guzzle": "Required to use the ping methods on schedules (^6.0).",
|
||||
"symfony/process": "Required to use scheduling component (^4.1)."
|
||||
"illuminate/filesystem": "Required to use the generator command (5.8.*)"
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
|
||||
@@ -17,6 +17,9 @@ class BoundMethod
|
||||
* @param array $parameters
|
||||
* @param string|null $defaultMethod
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public static function call($container, $callback, array $parameters = [], $defaultMethod = null)
|
||||
{
|
||||
@@ -107,6 +110,8 @@ class BoundMethod
|
||||
* @param callable|string $callback
|
||||
* @param array $parameters
|
||||
* @return array
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
protected static function getMethodDependencies($container, $callback, array $parameters = [])
|
||||
{
|
||||
@@ -145,7 +150,7 @@ class BoundMethod
|
||||
* @param \ReflectionParameter $parameter
|
||||
* @param array $parameters
|
||||
* @param array $dependencies
|
||||
* @return mixed
|
||||
* @return void
|
||||
*/
|
||||
protected static function addDependencyForCallParameter($container, $parameter,
|
||||
array &$parameters, &$dependencies)
|
||||
|
||||
93
vendor/laravel/framework/src/Illuminate/Container/Container.php
vendored
Normal file → Executable file
93
vendor/laravel/framework/src/Illuminate/Container/Container.php
vendored
Normal file → Executable file
@@ -24,112 +24,112 @@ class Container implements ArrayAccess, ContainerContract
|
||||
/**
|
||||
* An array of the types that have been resolved.
|
||||
*
|
||||
* @var array
|
||||
* @var bool[]
|
||||
*/
|
||||
protected $resolved = [];
|
||||
|
||||
/**
|
||||
* The container's bindings.
|
||||
*
|
||||
* @var array
|
||||
* @var array[]
|
||||
*/
|
||||
protected $bindings = [];
|
||||
|
||||
/**
|
||||
* The container's method bindings.
|
||||
*
|
||||
* @var array
|
||||
* @var \Closure[]
|
||||
*/
|
||||
protected $methodBindings = [];
|
||||
|
||||
/**
|
||||
* The container's shared instances.
|
||||
*
|
||||
* @var array
|
||||
* @var object[]
|
||||
*/
|
||||
protected $instances = [];
|
||||
|
||||
/**
|
||||
* The registered type aliases.
|
||||
*
|
||||
* @var array
|
||||
* @var string[]
|
||||
*/
|
||||
protected $aliases = [];
|
||||
|
||||
/**
|
||||
* The registered aliases keyed by the abstract name.
|
||||
*
|
||||
* @var array
|
||||
* @var array[]
|
||||
*/
|
||||
protected $abstractAliases = [];
|
||||
|
||||
/**
|
||||
* The extension closures for services.
|
||||
*
|
||||
* @var array
|
||||
* @var array[]
|
||||
*/
|
||||
protected $extenders = [];
|
||||
|
||||
/**
|
||||
* All of the registered tags.
|
||||
*
|
||||
* @var array
|
||||
* @var array[]
|
||||
*/
|
||||
protected $tags = [];
|
||||
|
||||
/**
|
||||
* The stack of concretions currently being built.
|
||||
*
|
||||
* @var array
|
||||
* @var array[]
|
||||
*/
|
||||
protected $buildStack = [];
|
||||
|
||||
/**
|
||||
* The parameter override stack.
|
||||
*
|
||||
* @var array
|
||||
* @var array[]
|
||||
*/
|
||||
protected $with = [];
|
||||
|
||||
/**
|
||||
* The contextual binding map.
|
||||
*
|
||||
* @var array
|
||||
* @var array[]
|
||||
*/
|
||||
public $contextual = [];
|
||||
|
||||
/**
|
||||
* All of the registered rebound callbacks.
|
||||
*
|
||||
* @var array
|
||||
* @var array[]
|
||||
*/
|
||||
protected $reboundCallbacks = [];
|
||||
|
||||
/**
|
||||
* All of the global resolving callbacks.
|
||||
*
|
||||
* @var array
|
||||
* @var \Closure[]
|
||||
*/
|
||||
protected $globalResolvingCallbacks = [];
|
||||
|
||||
/**
|
||||
* All of the global after resolving callbacks.
|
||||
*
|
||||
* @var array
|
||||
* @var \Closure[]
|
||||
*/
|
||||
protected $globalAfterResolvingCallbacks = [];
|
||||
|
||||
/**
|
||||
* All of the resolving callbacks by class type.
|
||||
*
|
||||
* @var array
|
||||
* @var array[]
|
||||
*/
|
||||
protected $resolvingCallbacks = [];
|
||||
|
||||
/**
|
||||
* All of the after resolving callbacks by class type.
|
||||
*
|
||||
* @var array
|
||||
* @var array[]
|
||||
*/
|
||||
protected $afterResolvingCallbacks = [];
|
||||
|
||||
@@ -261,7 +261,9 @@ class Container implements ArrayAccess, ContainerContract
|
||||
return $container->build($concrete);
|
||||
}
|
||||
|
||||
return $container->make($concrete, $parameters);
|
||||
return $container->resolve(
|
||||
$concrete, $parameters, $raiseEvents = false
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -455,19 +457,19 @@ class Container implements ArrayAccess, ContainerContract
|
||||
* Resolve all of the bindings for a given tag.
|
||||
*
|
||||
* @param string $tag
|
||||
* @return array
|
||||
* @return iterable
|
||||
*/
|
||||
public function tagged($tag)
|
||||
{
|
||||
$results = [];
|
||||
|
||||
if (isset($this->tags[$tag])) {
|
||||
foreach ($this->tags[$tag] as $abstract) {
|
||||
$results[] = $this->make($abstract);
|
||||
}
|
||||
if (! isset($this->tags[$tag])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $results;
|
||||
return new RewindableGenerator(function () use ($tag) {
|
||||
foreach ($this->tags[$tag] as $abstract) {
|
||||
yield $this->make($abstract);
|
||||
}
|
||||
}, count($this->tags[$tag]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -476,9 +478,15 @@ class Container implements ArrayAccess, ContainerContract
|
||||
* @param string $abstract
|
||||
* @param string $alias
|
||||
* @return void
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function alias($abstract, $alias)
|
||||
{
|
||||
if ($alias === $abstract) {
|
||||
throw new LogicException("[{$abstract}] is aliased to itself.");
|
||||
}
|
||||
|
||||
$this->aliases[$alias] = $abstract;
|
||||
|
||||
$this->abstractAliases[$abstract][] = $alias;
|
||||
@@ -538,11 +546,7 @@ class Container implements ArrayAccess, ContainerContract
|
||||
*/
|
||||
protected function getReboundCallbacks($abstract)
|
||||
{
|
||||
if (isset($this->reboundCallbacks[$abstract])) {
|
||||
return $this->reboundCallbacks[$abstract];
|
||||
}
|
||||
|
||||
return [];
|
||||
return $this->reboundCallbacks[$abstract] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -603,6 +607,8 @@ class Container implements ArrayAccess, ContainerContract
|
||||
* @param string $abstract
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function make($abstract, array $parameters = [])
|
||||
{
|
||||
@@ -630,9 +636,12 @@ class Container implements ArrayAccess, ContainerContract
|
||||
*
|
||||
* @param string $abstract
|
||||
* @param array $parameters
|
||||
* @param bool $raiseEvents
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
protected function resolve($abstract, $parameters = [])
|
||||
protected function resolve($abstract, $parameters = [], $raiseEvents = true)
|
||||
{
|
||||
$abstract = $this->getAlias($abstract);
|
||||
|
||||
@@ -674,7 +683,9 @@ class Container implements ArrayAccess, ContainerContract
|
||||
$this->instances[$abstract] = $object;
|
||||
}
|
||||
|
||||
$this->fireResolvingCallbacks($abstract, $object);
|
||||
if ($raiseEvents) {
|
||||
$this->fireResolvingCallbacks($abstract, $object);
|
||||
}
|
||||
|
||||
// Before returning, we will also set the resolved flag to "true" and pop off
|
||||
// the parameter overrides for this build. After those two things are done
|
||||
@@ -712,7 +723,7 @@ class Container implements ArrayAccess, ContainerContract
|
||||
* Get the contextual concrete binding for the given abstract.
|
||||
*
|
||||
* @param string $abstract
|
||||
* @return string|null
|
||||
* @return \Closure|string|null
|
||||
*/
|
||||
protected function getContextualConcrete($abstract)
|
||||
{
|
||||
@@ -738,7 +749,7 @@ class Container implements ArrayAccess, ContainerContract
|
||||
* Find the concrete binding for the given abstract in the contextual binding array.
|
||||
*
|
||||
* @param string $abstract
|
||||
* @return string|null
|
||||
* @return \Closure|string|null
|
||||
*/
|
||||
protected function findInContextualBindings($abstract)
|
||||
{
|
||||
@@ -817,6 +828,8 @@ class Container implements ArrayAccess, ContainerContract
|
||||
*
|
||||
* @param array $dependencies
|
||||
* @return array
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
protected function resolveDependencies(array $dependencies)
|
||||
{
|
||||
@@ -1085,8 +1098,6 @@ class Container implements ArrayAccess, ContainerContract
|
||||
*
|
||||
* @param string $abstract
|
||||
* @return string
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function getAlias($abstract)
|
||||
{
|
||||
@@ -1094,10 +1105,6 @@ class Container implements ArrayAccess, ContainerContract
|
||||
return $abstract;
|
||||
}
|
||||
|
||||
if ($this->aliases[$abstract] === $abstract) {
|
||||
throw new LogicException("[{$abstract}] is aliased to itself.");
|
||||
}
|
||||
|
||||
return $this->getAlias($this->aliases[$abstract]);
|
||||
}
|
||||
|
||||
@@ -1111,11 +1118,7 @@ class Container implements ArrayAccess, ContainerContract
|
||||
{
|
||||
$abstract = $this->getAlias($abstract);
|
||||
|
||||
if (isset($this->extenders[$abstract])) {
|
||||
return $this->extenders[$abstract];
|
||||
}
|
||||
|
||||
return [];
|
||||
return $this->extenders[$abstract] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Illuminate\Container;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Container\ContextualBindingBuilder as ContextualBindingBuilderContract;
|
||||
|
||||
class ContextualBindingBuilder implements ContextualBindingBuilderContract
|
||||
@@ -10,14 +11,14 @@ class ContextualBindingBuilder implements ContextualBindingBuilderContract
|
||||
/**
|
||||
* The underlying container instance.
|
||||
*
|
||||
* @var \Illuminate\Container\Container
|
||||
* @var \Illuminate\Contracts\Container\Container
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* The concrete instance.
|
||||
*
|
||||
* @var string
|
||||
* @var string|array
|
||||
*/
|
||||
protected $concrete;
|
||||
|
||||
@@ -31,7 +32,7 @@ class ContextualBindingBuilder implements ContextualBindingBuilderContract
|
||||
/**
|
||||
* Create a new contextual binding builder.
|
||||
*
|
||||
* @param \Illuminate\Container\Container $container
|
||||
* @param \Illuminate\Contracts\Container\Container $container
|
||||
* @param string|array $concrete
|
||||
* @return void
|
||||
*/
|
||||
|
||||
60
vendor/laravel/framework/src/Illuminate/Container/RewindableGenerator.php
vendored
Normal file
60
vendor/laravel/framework/src/Illuminate/Container/RewindableGenerator.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Container;
|
||||
|
||||
use Countable;
|
||||
use IteratorAggregate;
|
||||
|
||||
class RewindableGenerator implements Countable, IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* The generator callback.
|
||||
*
|
||||
* @var callable
|
||||
*/
|
||||
protected $generator;
|
||||
|
||||
/**
|
||||
* The number of tagged services.
|
||||
*
|
||||
* @var callable|int
|
||||
*/
|
||||
protected $count;
|
||||
|
||||
/**
|
||||
* Create a new generator instance.
|
||||
*
|
||||
* @param callable $generator
|
||||
* @param callable|int $count
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(callable $generator, $count)
|
||||
{
|
||||
$this->count = $count;
|
||||
$this->generator = $generator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an iterator from the generator.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return ($this->generator)();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of tagged services.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
if (is_callable($count = $this->count)) {
|
||||
$this->count = $count();
|
||||
}
|
||||
|
||||
return $this->count;
|
||||
}
|
||||
}
|
||||
6
vendor/laravel/framework/src/Illuminate/Container/composer.json
vendored
Normal file → Executable file
6
vendor/laravel/framework/src/Illuminate/Container/composer.json
vendored
Normal file → Executable file
@@ -15,8 +15,8 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"illuminate/contracts": "5.7.*",
|
||||
"illuminate/support": "5.7.*",
|
||||
"illuminate/contracts": "5.8.*",
|
||||
"illuminate/support": "5.8.*",
|
||||
"psr/container": "^1.0"
|
||||
},
|
||||
"autoload": {
|
||||
@@ -26,7 +26,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.7-dev"
|
||||
"dev-master": "5.8-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
||||
@@ -15,7 +15,7 @@ interface UserProvider
|
||||
/**
|
||||
* Retrieve a user by their unique identifier and "remember me" token.
|
||||
*
|
||||
* @param mixed $identifier
|
||||
* @param mixed $identifier
|
||||
* @param string $token
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ interface Lock
|
||||
* Attempt to acquire the lock.
|
||||
*
|
||||
* @param callable|null $callback
|
||||
* @return bool
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($callback = null);
|
||||
|
||||
@@ -27,4 +27,18 @@ interface Lock
|
||||
* @return void
|
||||
*/
|
||||
public function release();
|
||||
|
||||
/**
|
||||
* Returns the current owner of the lock.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function owner();
|
||||
|
||||
/**
|
||||
* Releases this lock in disregard of ownership.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function forceRelease();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,17 @@ interface LockProvider
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $seconds
|
||||
* @param string|null $owner
|
||||
* @return \Illuminate\Contracts\Cache\Lock
|
||||
*/
|
||||
public function lock($name, $seconds = 0);
|
||||
public function lock($name, $seconds = 0, $owner = null);
|
||||
|
||||
/**
|
||||
* Restore a lock instance using the owner identifier.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $owner
|
||||
* @return \Illuminate\Contracts\Cache\Lock
|
||||
*/
|
||||
public function restoreLock($name, $owner);
|
||||
}
|
||||
|
||||
@@ -7,23 +7,6 @@ use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
interface Repository extends CacheInterface
|
||||
{
|
||||
/**
|
||||
* Determine if an item exists in the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function has($key);
|
||||
|
||||
/**
|
||||
* Retrieve an item from the cache by key.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key, $default = null);
|
||||
|
||||
/**
|
||||
* Retrieve an item from the cache and delete it.
|
||||
*
|
||||
@@ -38,20 +21,20 @@ interface Repository extends CacheInterface
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param \DateTimeInterface|\DateInterval|float|int $minutes
|
||||
* @return void
|
||||
* @param \DateTimeInterface|\DateInterval|int|null $ttl
|
||||
* @return bool
|
||||
*/
|
||||
public function put($key, $value, $minutes);
|
||||
public function put($key, $value, $ttl = null);
|
||||
|
||||
/**
|
||||
* Store an item in the cache if the key does not exist.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param \DateTimeInterface|\DateInterval|float|int $minutes
|
||||
* @param \DateTimeInterface|\DateInterval|int|null $ttl
|
||||
* @return bool
|
||||
*/
|
||||
public function add($key, $value, $minutes);
|
||||
public function add($key, $value, $ttl = null);
|
||||
|
||||
/**
|
||||
* Increment the value of an item in the cache.
|
||||
@@ -76,7 +59,7 @@ interface Repository extends CacheInterface
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($key, $value);
|
||||
|
||||
@@ -84,11 +67,11 @@ interface Repository extends CacheInterface
|
||||
* Get an item from the cache, or execute the given Closure and store the result.
|
||||
*
|
||||
* @param string $key
|
||||
* @param \DateTimeInterface|\DateInterval|float|int $minutes
|
||||
* @param \DateTimeInterface|\DateInterval|int|null $ttl
|
||||
* @param \Closure $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function remember($key, $minutes, Closure $callback);
|
||||
public function remember($key, $ttl, Closure $callback);
|
||||
|
||||
/**
|
||||
* Get an item from the cache, or execute the given Closure and store the result forever.
|
||||
|
||||
@@ -23,23 +23,23 @@ interface Store
|
||||
public function many(array $keys);
|
||||
|
||||
/**
|
||||
* Store an item in the cache for a given number of minutes.
|
||||
* Store an item in the cache for a given number of seconds.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param float|int $minutes
|
||||
* @return void
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function put($key, $value, $minutes);
|
||||
public function put($key, $value, $seconds);
|
||||
|
||||
/**
|
||||
* Store multiple items in the cache for a given number of minutes.
|
||||
* Store multiple items in the cache for a given number of seconds.
|
||||
*
|
||||
* @param array $values
|
||||
* @param float|int $minutes
|
||||
* @return void
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function putMany(array $values, $minutes);
|
||||
public function putMany(array $values, $seconds);
|
||||
|
||||
/**
|
||||
* Increment the value of an item in the cache.
|
||||
@@ -64,7 +64,7 @@ interface Store
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($key, $value);
|
||||
|
||||
|
||||
@@ -45,4 +45,13 @@ interface Kernel
|
||||
* @return string
|
||||
*/
|
||||
public function output();
|
||||
|
||||
/**
|
||||
* Terminate the application.
|
||||
*
|
||||
* @param \Symfony\Component\Console\Input\InputInterface $input
|
||||
* @param int $status
|
||||
* @return void
|
||||
*/
|
||||
public function terminate($input, $status);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ interface Container extends ContainerInterface
|
||||
* @param string $abstract
|
||||
* @param string $alias
|
||||
* @return void
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function alias($abstract, $alias);
|
||||
|
||||
@@ -37,7 +39,7 @@ interface Container extends ContainerInterface
|
||||
* Resolve all of the bindings for a given tag.
|
||||
*
|
||||
* @param string $tag
|
||||
* @return array
|
||||
* @return iterable
|
||||
*/
|
||||
public function tagged($tag);
|
||||
|
||||
@@ -90,6 +92,16 @@ interface Container extends ContainerInterface
|
||||
*/
|
||||
public function instance($abstract, $instance);
|
||||
|
||||
/**
|
||||
* Add a contextual binding to the container.
|
||||
*
|
||||
* @param string $concrete
|
||||
* @param string $abstract
|
||||
* @param \Closure|string $implementation
|
||||
* @return void
|
||||
*/
|
||||
public function addContextualBinding($concrete, $abstract, $implementation);
|
||||
|
||||
/**
|
||||
* Define a contextual binding.
|
||||
*
|
||||
@@ -106,12 +118,21 @@ interface Container extends ContainerInterface
|
||||
*/
|
||||
public function factory($abstract);
|
||||
|
||||
/**
|
||||
* Flush the container of all bindings and resolved instances.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function flush();
|
||||
|
||||
/**
|
||||
* Resolve the given type from the container.
|
||||
*
|
||||
* @param string $abstract
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function make($abstract, array $parameters = []);
|
||||
|
||||
|
||||
8
vendor/laravel/framework/src/Illuminate/Contracts/Database/Events/MigrationEvent.php
vendored
Normal file
8
vendor/laravel/framework/src/Illuminate/Contracts/Database/Events/MigrationEvent.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Contracts\Database\Events;
|
||||
|
||||
interface MigrationEvent
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -14,6 +14,14 @@ interface ExceptionHandler
|
||||
*/
|
||||
public function report(Exception $e);
|
||||
|
||||
/**
|
||||
* Determine if the exception should be reported.
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldReport(Exception $e);
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
|
||||
@@ -10,6 +10,8 @@ interface Encrypter
|
||||
* @param mixed $value
|
||||
* @param bool $serialize
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Encryption\EncryptException
|
||||
*/
|
||||
public function encrypt($value, $serialize = true);
|
||||
|
||||
@@ -19,6 +21,8 @@ interface Encrypter
|
||||
* @param mixed $payload
|
||||
* @param bool $unserialize
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Encryption\DecryptException
|
||||
*/
|
||||
public function decrypt($payload, $unserialize = true);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ interface Filesystem
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $data
|
||||
* @return int
|
||||
* @return bool
|
||||
*/
|
||||
public function prepend($path, $data);
|
||||
|
||||
@@ -100,7 +100,7 @@ interface Filesystem
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $data
|
||||
* @return int
|
||||
* @return bool
|
||||
*/
|
||||
public function append($path, $data);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Illuminate\Contracts\Foundation;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
|
||||
interface Application extends Container
|
||||
@@ -21,11 +22,58 @@ interface Application extends Container
|
||||
public function basePath();
|
||||
|
||||
/**
|
||||
* Get or check the current application environment.
|
||||
* Get the path to the bootstrap directory.
|
||||
*
|
||||
* @param string $path Optionally, a path to append to the bootstrap path
|
||||
* @return string
|
||||
*/
|
||||
public function bootstrapPath($path = '');
|
||||
|
||||
/**
|
||||
* Get the path to the application configuration files.
|
||||
*
|
||||
* @param string $path Optionally, a path to append to the config path
|
||||
* @return string
|
||||
*/
|
||||
public function configPath($path = '');
|
||||
|
||||
/**
|
||||
* Get the path to the database directory.
|
||||
*
|
||||
* @param string $path Optionally, a path to append to the database path
|
||||
* @return string
|
||||
*/
|
||||
public function databasePath($path = '');
|
||||
|
||||
/**
|
||||
* Get the path to the environment file directory.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function environment();
|
||||
public function environmentPath();
|
||||
|
||||
/**
|
||||
* Get the path to the resources directory.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function resourcePath($path = '');
|
||||
|
||||
/**
|
||||
* Get the path to the storage directory.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function storagePath();
|
||||
|
||||
/**
|
||||
* Get or check the current application environment.
|
||||
*
|
||||
* @param string|array $environments
|
||||
* @return string|bool
|
||||
*/
|
||||
public function environment(...$environments);
|
||||
|
||||
/**
|
||||
* Determine if the application is running in the console.
|
||||
@@ -73,6 +121,14 @@ interface Application extends Container
|
||||
*/
|
||||
public function registerDeferredProvider($provider, $service = null);
|
||||
|
||||
/**
|
||||
* Resolve a service provider instance from the class name.
|
||||
*
|
||||
* @param string $provider
|
||||
* @return \Illuminate\Support\ServiceProvider
|
||||
*/
|
||||
public function resolveProvider($provider);
|
||||
|
||||
/**
|
||||
* Boot the application's service providers.
|
||||
*
|
||||
@@ -83,7 +139,7 @@ interface Application extends Container
|
||||
/**
|
||||
* Register a new boot listener.
|
||||
*
|
||||
* @param mixed $callback
|
||||
* @param callable $callback
|
||||
* @return void
|
||||
*/
|
||||
public function booting($callback);
|
||||
@@ -91,11 +147,55 @@ interface Application extends Container
|
||||
/**
|
||||
* Register a new "booted" listener.
|
||||
*
|
||||
* @param mixed $callback
|
||||
* @param callable $callback
|
||||
* @return void
|
||||
*/
|
||||
public function booted($callback);
|
||||
|
||||
/**
|
||||
* Run the given array of bootstrap classes.
|
||||
*
|
||||
* @param array $bootstrappers
|
||||
* @return void
|
||||
*/
|
||||
public function bootstrapWith(array $bootstrappers);
|
||||
|
||||
/**
|
||||
* Determine if the application configuration is cached.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function configurationIsCached();
|
||||
|
||||
/**
|
||||
* Detect the application's current environment.
|
||||
*
|
||||
* @param \Closure $callback
|
||||
* @return string
|
||||
*/
|
||||
public function detectEnvironment(Closure $callback);
|
||||
|
||||
/**
|
||||
* Get the environment file the application is using.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function environmentFile();
|
||||
|
||||
/**
|
||||
* Get the fully qualified path to the environment file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function environmentFilePath();
|
||||
|
||||
/**
|
||||
* Get the path to the configuration cache file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCachedConfigPath();
|
||||
|
||||
/**
|
||||
* Get the path to the cached services.php file.
|
||||
*
|
||||
@@ -109,4 +209,86 @@ interface Application extends Container
|
||||
* @return string
|
||||
*/
|
||||
public function getCachedPackagesPath();
|
||||
|
||||
/**
|
||||
* Get the path to the routes cache file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCachedRoutesPath();
|
||||
|
||||
/**
|
||||
* Get the current application locale.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLocale();
|
||||
|
||||
/**
|
||||
* Get the application namespace.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function getNamespace();
|
||||
|
||||
/**
|
||||
* Get the registered service provider instances if any exist.
|
||||
*
|
||||
* @param \Illuminate\Support\ServiceProvider|string $provider
|
||||
* @return array
|
||||
*/
|
||||
public function getProviders($provider);
|
||||
|
||||
/**
|
||||
* Determine if the application has been bootstrapped before.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasBeenBootstrapped();
|
||||
|
||||
/**
|
||||
* Load and boot all of the remaining deferred providers.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadDeferredProviders();
|
||||
|
||||
/**
|
||||
* Set the environment file to be loaded during bootstrapping.
|
||||
*
|
||||
* @param string $file
|
||||
* @return $this
|
||||
*/
|
||||
public function loadEnvironmentFrom($file);
|
||||
|
||||
/**
|
||||
* Determine if the application routes are cached.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function routesAreCached();
|
||||
|
||||
/**
|
||||
* Set the current application locale.
|
||||
*
|
||||
* @param string $locale
|
||||
* @return void
|
||||
*/
|
||||
public function setLocale($locale);
|
||||
|
||||
/**
|
||||
* Determine if middleware has been disabled for the application.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSkipMiddleware();
|
||||
|
||||
/**
|
||||
* Terminate the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function terminate();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ interface Mailable
|
||||
/**
|
||||
* Deliver the queued message after the given delay.
|
||||
*
|
||||
* @param \DateTime|int $delay
|
||||
* @param \DateTimeInterface|\DateInterval|int $delay
|
||||
* @param \Illuminate\Contracts\Queue\Factory $queue
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,7 @@ interface Mailer
|
||||
public function bcc($users);
|
||||
|
||||
/**
|
||||
* Send a new message when only a raw text part.
|
||||
* Send a new message with only a raw text part.
|
||||
*
|
||||
* @param string $text
|
||||
* @param mixed $callback
|
||||
|
||||
@@ -28,11 +28,20 @@ interface Job
|
||||
/**
|
||||
* Release the job back into the queue.
|
||||
*
|
||||
* Accepts a delay specified in seconds.
|
||||
*
|
||||
* @param int $delay
|
||||
* @return void
|
||||
*/
|
||||
public function release($delay = 0);
|
||||
|
||||
/**
|
||||
* Determine if the job was released back into the queue.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isReleased();
|
||||
|
||||
/**
|
||||
* Delete the job from the queue.
|
||||
*
|
||||
@@ -62,12 +71,26 @@ interface Job
|
||||
public function attempts();
|
||||
|
||||
/**
|
||||
* Process an exception that caused the job to fail.
|
||||
* Determine if the job has been marked as a failure.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasFailed();
|
||||
|
||||
/**
|
||||
* Mark the job as "failed".
|
||||
*
|
||||
* @param \Throwable $e
|
||||
* @return void
|
||||
*/
|
||||
public function failed($e);
|
||||
public function markAsFailed();
|
||||
|
||||
/**
|
||||
* Delete the job, call the "failed" method, and raise the failed job event.
|
||||
*
|
||||
* @param \Throwable|null $e
|
||||
* @return void
|
||||
*/
|
||||
public function fail($e = null);
|
||||
|
||||
/**
|
||||
* Get the number of times to attempt a job.
|
||||
|
||||
@@ -37,7 +37,7 @@ interface ResponseFactory
|
||||
/**
|
||||
* Create a new JSON response instance.
|
||||
*
|
||||
* @param string|array $data
|
||||
* @param string|array|object $data
|
||||
* @param int $status
|
||||
* @param array $headers
|
||||
* @param int $options
|
||||
@@ -49,7 +49,7 @@ interface ResponseFactory
|
||||
* Create a new JSONP response instance.
|
||||
*
|
||||
* @param string $callback
|
||||
* @param string|array $data
|
||||
* @param string|array|object $data
|
||||
* @param int $status
|
||||
* @param array $headers
|
||||
* @param int $options
|
||||
@@ -89,6 +89,15 @@ interface ResponseFactory
|
||||
*/
|
||||
public function download($file, $name = null, array $headers = [], $disposition = 'attachment');
|
||||
|
||||
/**
|
||||
* Return the raw contents of a binary file.
|
||||
*
|
||||
* @param \SplFileInfo|string $file
|
||||
* @param array $headers
|
||||
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
|
||||
*/
|
||||
public function file($file, array $headers = []);
|
||||
|
||||
/**
|
||||
* Create a new redirect response to the given path.
|
||||
*
|
||||
|
||||
@@ -11,6 +11,14 @@ interface UrlGenerator
|
||||
*/
|
||||
public function current();
|
||||
|
||||
/**
|
||||
* Get the URL for the previous request.
|
||||
*
|
||||
* @param mixed $fallback
|
||||
* @return string
|
||||
*/
|
||||
public function previous($fallback = false);
|
||||
|
||||
/**
|
||||
* Generate an absolute URL to the given path.
|
||||
*
|
||||
|
||||
0
vendor/laravel/framework/src/Illuminate/Contracts/Support/Arrayable.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Contracts/Support/Arrayable.php
vendored
Normal file → Executable file
13
vendor/laravel/framework/src/Illuminate/Contracts/Support/DeferrableProvider.php
vendored
Normal file
13
vendor/laravel/framework/src/Illuminate/Contracts/Support/DeferrableProvider.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Contracts\Support;
|
||||
|
||||
interface DeferrableProvider
|
||||
{
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides();
|
||||
}
|
||||
0
vendor/laravel/framework/src/Illuminate/Contracts/Support/Jsonable.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Contracts/Support/Jsonable.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Contracts/Support/MessageProvider.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Contracts/Support/MessageProvider.php
vendored
Normal file → Executable file
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user