Commaaa2
This commit is contained in:
6
vendor/laravel/framework/README.md
vendored
6
vendor/laravel/framework/README.md
vendored
@@ -2,9 +2,9 @@
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||
</p>
|
||||
|
||||
## About Laravel
|
||||
|
||||
97
vendor/laravel/framework/composer.json
vendored
97
vendor/laravel/framework/composer.json
vendored
@@ -15,41 +15,43 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2.5|^8.0",
|
||||
"php": "^7.3|^8.0",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-openssl": "*",
|
||||
"doctrine/inflector": "^1.4|^2.0",
|
||||
"dragonmantank/cron-expression": "^2.3.1",
|
||||
"dragonmantank/cron-expression": "^3.0.2",
|
||||
"egulias/email-validator": "^2.1.10",
|
||||
"league/commonmark": "^1.3",
|
||||
"laravel/serializable-closure": "^1.0",
|
||||
"league/commonmark": "^1.3|^2.0.2",
|
||||
"league/flysystem": "^1.1",
|
||||
"monolog/monolog": "^2.0",
|
||||
"nesbot/carbon": "^2.31",
|
||||
"nesbot/carbon": "^2.53.1",
|
||||
"opis/closure": "^3.6",
|
||||
"psr/container": "^1.0",
|
||||
"psr/log": "^1.0|^2.0",
|
||||
"psr/simple-cache": "^1.0",
|
||||
"ramsey/uuid": "^3.7|^4.0",
|
||||
"swiftmailer/swiftmailer": "^6.0",
|
||||
"symfony/console": "^5.0",
|
||||
"symfony/error-handler": "^5.0",
|
||||
"symfony/finder": "^5.0",
|
||||
"symfony/http-foundation": "^5.0",
|
||||
"symfony/http-kernel": "^5.0",
|
||||
"symfony/mime": "^5.0",
|
||||
"symfony/polyfill-php73": "^1.17",
|
||||
"symfony/process": "^5.0",
|
||||
"symfony/routing": "^5.0",
|
||||
"symfony/var-dumper": "^5.0",
|
||||
"ramsey/uuid": "^4.2.2",
|
||||
"swiftmailer/swiftmailer": "^6.3",
|
||||
"symfony/console": "^5.4",
|
||||
"symfony/error-handler": "^5.4",
|
||||
"symfony/finder": "^5.4",
|
||||
"symfony/http-foundation": "^5.4",
|
||||
"symfony/http-kernel": "^5.4",
|
||||
"symfony/mime": "^5.4",
|
||||
"symfony/process": "^5.4",
|
||||
"symfony/routing": "^5.4",
|
||||
"symfony/var-dumper": "^5.4",
|
||||
"tijsverkoyen/css-to-inline-styles": "^2.2.2",
|
||||
"vlucas/phpdotenv": "^4.0",
|
||||
"voku/portable-ascii": "^1.4.8"
|
||||
"vlucas/phpdotenv": "^5.4.1",
|
||||
"voku/portable-ascii": "^1.6.1"
|
||||
},
|
||||
"replace": {
|
||||
"illuminate/auth": "self.version",
|
||||
"illuminate/broadcasting": "self.version",
|
||||
"illuminate/bus": "self.version",
|
||||
"illuminate/cache": "self.version",
|
||||
"illuminate/collections": "self.version",
|
||||
"illuminate/config": "self.version",
|
||||
"illuminate/console": "self.version",
|
||||
"illuminate/container": "self.version",
|
||||
@@ -62,6 +64,7 @@
|
||||
"illuminate/hashing": "self.version",
|
||||
"illuminate/http": "self.version",
|
||||
"illuminate/log": "self.version",
|
||||
"illuminate/macroable": "self.version",
|
||||
"illuminate/mail": "self.version",
|
||||
"illuminate/notifications": "self.version",
|
||||
"illuminate/pagination": "self.version",
|
||||
@@ -77,32 +80,35 @@
|
||||
"illuminate/view": "self.version"
|
||||
},
|
||||
"require-dev": {
|
||||
"aws/aws-sdk-php": "^3.155",
|
||||
"doctrine/dbal": "^2.6",
|
||||
"filp/whoops": "^2.8",
|
||||
"guzzlehttp/guzzle": "^6.3.1|^7.0.1",
|
||||
"aws/aws-sdk-php": "^3.198.1",
|
||||
"doctrine/dbal": "^2.13.3|^3.1.4",
|
||||
"filp/whoops": "^2.14.3",
|
||||
"guzzlehttp/guzzle": "^6.5.5|^7.0.1",
|
||||
"league/flysystem-cached-adapter": "^1.0",
|
||||
"mockery/mockery": "~1.3.3|^1.4.2",
|
||||
"moontoast/math": "^1.1",
|
||||
"orchestra/testbench-core": "^5.8",
|
||||
"mockery/mockery": "^1.4.4",
|
||||
"orchestra/testbench-core": "^6.27",
|
||||
"pda/pheanstalk": "^4.0",
|
||||
"phpunit/phpunit": "^8.4|^9.3.3",
|
||||
"predis/predis": "^1.1.1",
|
||||
"symfony/cache": "^5.0"
|
||||
"phpunit/phpunit": "^8.5.19|^9.5.8",
|
||||
"predis/predis": "^1.1.9",
|
||||
"symfony/cache": "^5.4"
|
||||
},
|
||||
"provide": {
|
||||
"psr/container-implementation": "1.0"
|
||||
"psr/container-implementation": "1.0",
|
||||
"psr/simple-cache-implementation": "1.0"
|
||||
},
|
||||
"conflict": {
|
||||
"tightenco/collect": "<5.5.33"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/Illuminate/Collections/helpers.php",
|
||||
"src/Illuminate/Events/functions.php",
|
||||
"src/Illuminate/Foundation/helpers.php",
|
||||
"src/Illuminate/Support/helpers.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Illuminate\\": "src/Illuminate/"
|
||||
"Illuminate\\": "src/Illuminate/",
|
||||
"Illuminate\\Support\\": ["src/Illuminate/Macroable/", "src/Illuminate/Collections/"]
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
@@ -115,40 +121,45 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "7.x-dev"
|
||||
"dev-master": "8.x-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"ext-bcmath": "Required to use the multiple_of validation rule.",
|
||||
"ext-ftp": "Required to use the Flysystem FTP driver.",
|
||||
"ext-gd": "Required to use Illuminate\\Http\\Testing\\FileFactory::image().",
|
||||
"ext-memcached": "Required to use the memcache cache driver.",
|
||||
"ext-pcntl": "Required to use all features of the queue worker.",
|
||||
"ext-posix": "Required to use all features of the queue worker.",
|
||||
"ext-redis": "Required to use the Redis cache and queue drivers (^4.0|^5.0).",
|
||||
"aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.155).",
|
||||
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.6).",
|
||||
"filp/whoops": "Required for friendly error pages in development (^2.8).",
|
||||
"ably/ably-php": "Required to use the Ably broadcast driver (^1.0).",
|
||||
"aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.198.1).",
|
||||
"brianium/paratest": "Required to run tests in parallel (^6.0).",
|
||||
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.13.3|^3.1.4).",
|
||||
"filp/whoops": "Required for friendly error pages in development (^2.14.3).",
|
||||
"fakerphp/faker": "Required to use the eloquent factory builder (^1.9.1).",
|
||||
"guzzlehttp/guzzle": "Required to use the HTTP Client, Mailgun mail driver and the ping methods on schedules (^6.3.1|^7.0.1).",
|
||||
"guzzlehttp/guzzle": "Required to use the HTTP Client, Mailgun mail driver and the ping methods on schedules (^6.5.5|^7.0.1).",
|
||||
"laravel/tinker": "Required to use the tinker console command (^2.0).",
|
||||
"league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^1.0).",
|
||||
"league/flysystem-cached-adapter": "Required to use the Flysystem cache (^1.0).",
|
||||
"league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^1.0).",
|
||||
"mockery/mockery": "Required to use mocking (~1.3.3|^1.4.2).",
|
||||
"moontoast/math": "Required to use ordered UUIDs (^1.1).",
|
||||
"mockery/mockery": "Required to use mocking (^1.4.4).",
|
||||
"nyholm/psr7": "Required to use PSR-7 bridging features (^1.2).",
|
||||
"pda/pheanstalk": "Required to use the beanstalk queue driver (^4.0).",
|
||||
"phpunit/phpunit": "Required to use assertions and run tests (^8.4|^9.3.3).",
|
||||
"predis/predis": "Required to use the predis connector (^1.1.2).",
|
||||
"phpunit/phpunit": "Required to use assertions and run tests (^8.5.19|^9.5.8).",
|
||||
"predis/predis": "Required to use the predis connector (^1.1.9).",
|
||||
"psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).",
|
||||
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0).",
|
||||
"symfony/cache": "Required to PSR-6 cache bridge (^5.0).",
|
||||
"symfony/filesystem": "Required to create relative storage directory symbolic links (^5.0).",
|
||||
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0|^5.0|^6.0|^7.0).",
|
||||
"symfony/cache": "Required to PSR-6 cache bridge (^5.4).",
|
||||
"symfony/filesystem": "Required to enable support for relative symbolic links (^5.4).",
|
||||
"symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^2.0).",
|
||||
"wildbit/swiftmailer-postmark": "Required to use Postmark mail driver (^3.0)."
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"composer/package-versions-deprecated": true
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
|
||||
namespace Illuminate\Auth\Access;
|
||||
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use InvalidArgumentException;
|
||||
use ReflectionClass;
|
||||
@@ -115,6 +118,64 @@ class Gate implements GateContract
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform an on-demand authorization check. Throw an authorization exception if the condition or callback is false.
|
||||
*
|
||||
* @param \Illuminate\Auth\Access\Response|\Closure|bool $condition
|
||||
* @param string|null $message
|
||||
* @param string|null $code
|
||||
* @return \Illuminate\Auth\Access\Response
|
||||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function allowIf($condition, $message = null, $code = null)
|
||||
{
|
||||
return $this->authorizeOnDemand($condition, $message, $code, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform an on-demand authorization check. Throw an authorization exception if the condition or callback is true.
|
||||
*
|
||||
* @param \Illuminate\Auth\Access\Response|\Closure|bool $condition
|
||||
* @param string|null $message
|
||||
* @param string|null $code
|
||||
* @return \Illuminate\Auth\Access\Response
|
||||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function denyIf($condition, $message = null, $code = null)
|
||||
{
|
||||
return $this->authorizeOnDemand($condition, $message, $code, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Authorize a given condition or callback.
|
||||
*
|
||||
* @param \Illuminate\Auth\Access\Response|\Closure|bool $condition
|
||||
* @param string|null $message
|
||||
* @param string|null $code
|
||||
* @param bool $allowWhenResponseIs
|
||||
* @return \Illuminate\Auth\Access\Response
|
||||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
protected function authorizeOnDemand($condition, $message, $code, $allowWhenResponseIs)
|
||||
{
|
||||
$user = $this->resolveUser();
|
||||
|
||||
if ($condition instanceof Closure) {
|
||||
$response = $this->canBeCalledWithUser($user, $condition)
|
||||
? $condition($user)
|
||||
: new Response(false, $message, $code);
|
||||
} else {
|
||||
$response = $condition;
|
||||
}
|
||||
|
||||
return with($response instanceof Response ? $response : new Response(
|
||||
(bool) $response === $allowWhenResponseIs, $message, $code
|
||||
))->authorize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define a new ability.
|
||||
*
|
||||
@@ -155,10 +216,10 @@ class Gate implements GateContract
|
||||
{
|
||||
$abilities = $abilities ?: [
|
||||
'viewAny' => 'viewAny',
|
||||
'view' => 'view',
|
||||
'create' => 'create',
|
||||
'update' => 'update',
|
||||
'delete' => 'delete',
|
||||
'view' => 'view',
|
||||
'create' => 'create',
|
||||
'update' => 'update',
|
||||
'delete' => 'delete',
|
||||
];
|
||||
|
||||
foreach ($abilities as $ability => $method) {
|
||||
@@ -373,9 +434,11 @@ class Gate implements GateContract
|
||||
// After calling the authorization callback, we will call the "after" callbacks
|
||||
// that are registered with the Gate, which allows a developer to do logging
|
||||
// if that is required for this application. Then we'll return the result.
|
||||
return $this->callAfterCallbacks(
|
||||
return tap($this->callAfterCallbacks(
|
||||
$user, $ability, $arguments, $result
|
||||
);
|
||||
), function ($result) use ($user, $ability, $arguments) {
|
||||
$this->dispatchGateEvaluatedEvent($user, $ability, $arguments, $result);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -518,6 +581,24 @@ class Gate implements GateContract
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a gate evaluation event.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable|null $user
|
||||
* @param string $ability
|
||||
* @param array $arguments
|
||||
* @param bool|null $result
|
||||
* @return void
|
||||
*/
|
||||
protected function dispatchGateEvaluatedEvent($user, $ability, array $arguments, $result)
|
||||
{
|
||||
if ($this->container->bound(Dispatcher::class)) {
|
||||
$this->container->make(Dispatcher::class)->dispatch(
|
||||
new Events\GateEvaluated($user, $ability, $result, $arguments)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the callable for the given ability and arguments.
|
||||
*
|
||||
@@ -599,7 +680,15 @@ class Gate implements GateContract
|
||||
|
||||
$classDirname = str_replace('/', '\\', dirname(str_replace('\\', '/', $class)));
|
||||
|
||||
return [$classDirname.'\\Policies\\'.class_basename($class).'Policy'];
|
||||
$classDirnameSegments = explode('\\', $classDirname);
|
||||
|
||||
return Arr::wrap(Collection::times(count($classDirnameSegments), function ($index) use ($class, $classDirnameSegments) {
|
||||
$classDirname = implode('\\', array_slice($classDirnameSegments, 0, $index));
|
||||
|
||||
return $classDirname.'\\Policies\\'.class_basename($class).'Policy';
|
||||
})->reverse()->values()->first(function ($class) {
|
||||
return class_exists($class);
|
||||
}) ?: [$classDirname.'\\Policies\\'.class_basename($class).'Policy']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -770,4 +859,17 @@ class Gate implements GateContract
|
||||
{
|
||||
return $this->policies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the container instance used by the gate.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Container\Container $container
|
||||
* @return $this
|
||||
*/
|
||||
public function setContainer(Container $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
35
vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php
vendored
Normal file → Executable file
35
vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php
vendored
Normal file → Executable file
@@ -122,7 +122,11 @@ class AuthManager implements FactoryContract
|
||||
{
|
||||
$provider = $this->createUserProvider($config['provider'] ?? null);
|
||||
|
||||
$guard = new SessionGuard($name, $provider, $this->app['session.store']);
|
||||
$guard = new SessionGuard(
|
||||
$name,
|
||||
$provider,
|
||||
$this->app['session.store'],
|
||||
);
|
||||
|
||||
// When using the remember me functionality of the authentication services we
|
||||
// will need to be set the encryption instance of the guard, which allows
|
||||
@@ -139,6 +143,10 @@ class AuthManager implements FactoryContract
|
||||
$guard->setRequest($this->app->refresh('request', $guard, 'setRequest'));
|
||||
}
|
||||
|
||||
if (isset($config['remember'])) {
|
||||
$guard->setRememberDuration($config['remember']);
|
||||
}
|
||||
|
||||
return $guard;
|
||||
}
|
||||
|
||||
@@ -295,6 +303,31 @@ class AuthManager implements FactoryContract
|
||||
return count($this->guards) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forget all of the resolved guard instances.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function forgetGuards()
|
||||
{
|
||||
$this->guards = [];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the application instance used by the manager.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
* @return $this
|
||||
*/
|
||||
public function setApplication($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call the default driver instance.
|
||||
*
|
||||
|
||||
36
vendor/laravel/framework/src/Illuminate/Auth/AuthServiceProvider.php
vendored
Normal file → Executable file
36
vendor/laravel/framework/src/Illuminate/Auth/AuthServiceProvider.php
vendored
Normal file → Executable file
@@ -35,11 +35,6 @@ class AuthServiceProvider extends ServiceProvider
|
||||
protected function registerAuthenticator()
|
||||
{
|
||||
$this->app->singleton('auth', function ($app) {
|
||||
// Once the authentication service has actually been requested by the developer
|
||||
// we will set a variable in the application indicating such. This helps us
|
||||
// know that we need to set any queued cookies in the after event later.
|
||||
$app['auth.loaded'] = true;
|
||||
|
||||
return new AuthManager($app);
|
||||
});
|
||||
|
||||
@@ -55,11 +50,9 @@ class AuthServiceProvider extends ServiceProvider
|
||||
*/
|
||||
protected function registerUserResolver()
|
||||
{
|
||||
$this->app->bind(
|
||||
AuthenticatableContract::class, function ($app) {
|
||||
return call_user_func($app['auth']->userResolver());
|
||||
}
|
||||
);
|
||||
$this->app->bind(AuthenticatableContract::class, function ($app) {
|
||||
return call_user_func($app['auth']->userResolver());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,15 +76,13 @@ class AuthServiceProvider extends ServiceProvider
|
||||
*/
|
||||
protected function registerRequirePassword()
|
||||
{
|
||||
$this->app->bind(
|
||||
RequirePassword::class, function ($app) {
|
||||
return new RequirePassword(
|
||||
$app[ResponseFactory::class],
|
||||
$app[UrlGenerator::class],
|
||||
$app['config']->get('auth.password_timeout')
|
||||
);
|
||||
}
|
||||
);
|
||||
$this->app->bind(RequirePassword::class, function ($app) {
|
||||
return new RequirePassword(
|
||||
$app[ResponseFactory::class],
|
||||
$app[UrlGenerator::class],
|
||||
$app['config']->get('auth.password_timeout')
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,11 +107,8 @@ class AuthServiceProvider extends ServiceProvider
|
||||
protected function registerEventRebindHandler()
|
||||
{
|
||||
$this->app->rebinding('events', function ($app, $dispatcher) {
|
||||
if (! $app->resolved('auth')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($app['auth']->hasResolvedGuards() === false) {
|
||||
if (! $app->resolved('auth') ||
|
||||
$app['auth']->hasResolvedGuards() === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,16 @@ trait Authenticatable
|
||||
return $this->{$this->getAuthIdentifierName()};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unique broadcast identifier for the user.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAuthIdentifierForBroadcasting()
|
||||
{
|
||||
return $this->getAuthIdentifier();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the password for the user.
|
||||
*
|
||||
|
||||
@@ -16,7 +16,7 @@ class AuthenticationException extends Exception
|
||||
/**
|
||||
* The path the user should be redirected to.
|
||||
*
|
||||
* @var string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $redirectTo;
|
||||
|
||||
@@ -49,7 +49,7 @@ class AuthenticationException extends Exception
|
||||
/**
|
||||
* Get the path the user should be redirected to.
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function redirectTo()
|
||||
{
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
<script src="{{ asset('js/app.js') }}" defer></script>
|
||||
|
||||
<!-- Fonts -->
|
||||
<link rel="dns-prefetch" href="//fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Nunito&display=swap" rel="stylesheet">
|
||||
|
||||
<!-- Styles -->
|
||||
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
|
||||
|
||||
3
vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php
vendored
Normal file → Executable file
3
vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php
vendored
Normal file → Executable file
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
|
||||
@@ -117,6 +118,8 @@ class DatabaseUserProvider implements UserProvider
|
||||
|
||||
if (is_array($value) || $value instanceof Arrayable) {
|
||||
$query->whereIn($key, $value);
|
||||
} elseif ($value instanceof Closure) {
|
||||
$value($query);
|
||||
} else {
|
||||
$query->where($key, $value);
|
||||
}
|
||||
|
||||
3
vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php
vendored
Normal file → Executable file
3
vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php
vendored
Normal file → Executable file
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
|
||||
@@ -123,6 +124,8 @@ class EloquentUserProvider implements UserProvider
|
||||
|
||||
if (is_array($value) || $value instanceof Arrayable) {
|
||||
$query->whereIn($key, $value);
|
||||
} elseif ($value instanceof Closure) {
|
||||
$value($query);
|
||||
} else {
|
||||
$query->where($key, $value);
|
||||
}
|
||||
|
||||
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
@@ -25,7 +25,7 @@ trait GuardHelpers
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* Determine if current user is authenticated. If not, throw an exception.
|
||||
* Determine if the current user is authenticated. If not, throw an exception.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable
|
||||
*
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Illuminate\Auth\Middleware;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
class EnsureEmailIsVerified
|
||||
{
|
||||
@@ -14,7 +15,7 @@ class EnsureEmailIsVerified
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $redirectToRoute
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse|null
|
||||
*/
|
||||
public function handle($request, Closure $next, $redirectToRoute = null)
|
||||
{
|
||||
@@ -23,7 +24,7 @@ class EnsureEmailIsVerified
|
||||
! $request->user()->hasVerifiedEmail())) {
|
||||
return $request->expectsJson()
|
||||
? abort(403, 'Your email address is not verified.')
|
||||
: Redirect::route($redirectToRoute ?: 'verification.notice');
|
||||
: Redirect::guest(URL::route($redirectToRoute ?: 'verification.notice'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
@@ -63,15 +63,17 @@ class ResetPassword extends Notification
|
||||
return call_user_func(static::$toMailCallback, $notifiable, $this->token);
|
||||
}
|
||||
|
||||
if (static::$createUrlCallback) {
|
||||
$url = call_user_func(static::$createUrlCallback, $notifiable, $this->token);
|
||||
} else {
|
||||
$url = url(route('password.reset', [
|
||||
'token' => $this->token,
|
||||
'email' => $notifiable->getEmailForPasswordReset(),
|
||||
], false));
|
||||
}
|
||||
return $this->buildMailMessage($this->resetUrl($notifiable));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the reset password notification mail message for the given URL.
|
||||
*
|
||||
* @param string $url
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
protected function buildMailMessage($url)
|
||||
{
|
||||
return (new MailMessage)
|
||||
->subject(Lang::get('Reset Password Notification'))
|
||||
->line(Lang::get('You are receiving this email because we received a password reset request for your account.'))
|
||||
@@ -80,6 +82,24 @@ class ResetPassword extends Notification
|
||||
->line(Lang::get('If you did not request a password reset, no further action is required.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the reset URL for the given notifiable.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return string
|
||||
*/
|
||||
protected function resetUrl($notifiable)
|
||||
{
|
||||
if (static::$createUrlCallback) {
|
||||
return call_user_func(static::$createUrlCallback, $notifiable, $this->token);
|
||||
}
|
||||
|
||||
return url(route('password.reset', [
|
||||
'token' => $this->token,
|
||||
'email' => $notifiable->getEmailForPasswordReset(),
|
||||
], false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback that should be used when creating the reset password button URL.
|
||||
*
|
||||
|
||||
@@ -11,6 +11,13 @@ use Illuminate\Support\Facades\URL;
|
||||
|
||||
class VerifyEmail extends Notification
|
||||
{
|
||||
/**
|
||||
* The callback that should be used to create the verify email URL.
|
||||
*
|
||||
* @var \Closure|null
|
||||
*/
|
||||
public static $createUrlCallback;
|
||||
|
||||
/**
|
||||
* The callback that should be used to build the mail message.
|
||||
*
|
||||
@@ -43,10 +50,21 @@ class VerifyEmail extends Notification
|
||||
return call_user_func(static::$toMailCallback, $notifiable, $verificationUrl);
|
||||
}
|
||||
|
||||
return $this->buildMailMessage($verificationUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the verify email notification mail message for the given URL.
|
||||
*
|
||||
* @param string $url
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
protected function buildMailMessage($url)
|
||||
{
|
||||
return (new MailMessage)
|
||||
->subject(Lang::get('Verify Email Address'))
|
||||
->line(Lang::get('Please click the button below to verify your email address.'))
|
||||
->action(Lang::get('Verify Email Address'), $verificationUrl)
|
||||
->action(Lang::get('Verify Email Address'), $url)
|
||||
->line(Lang::get('If you did not create an account, no further action is required.'));
|
||||
}
|
||||
|
||||
@@ -58,6 +76,10 @@ class VerifyEmail extends Notification
|
||||
*/
|
||||
protected function verificationUrl($notifiable)
|
||||
{
|
||||
if (static::$createUrlCallback) {
|
||||
return call_user_func(static::$createUrlCallback, $notifiable);
|
||||
}
|
||||
|
||||
return URL::temporarySignedRoute(
|
||||
'verification.verify',
|
||||
Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)),
|
||||
@@ -68,6 +90,17 @@ class VerifyEmail extends Notification
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback that should be used when creating the email verification URL.
|
||||
*
|
||||
* @param \Closure $callback
|
||||
* @return void
|
||||
*/
|
||||
public static function createUrlUsing($callback)
|
||||
{
|
||||
static::$createUrlCallback = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback that should be used when building the notification mail message.
|
||||
*
|
||||
|
||||
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
19
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
vendored
Normal file → Executable file
19
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
vendored
Normal file → Executable file
@@ -42,9 +42,10 @@ class PasswordBroker implements PasswordBrokerContract
|
||||
* Send a password reset link to a user.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param \Closure|null $callback
|
||||
* @return string
|
||||
*/
|
||||
public function sendResetLink(array $credentials)
|
||||
public function sendResetLink(array $credentials, Closure $callback = null)
|
||||
{
|
||||
// First we will check to see if we found a user at the given credentials and
|
||||
// if we did not we will redirect back to this current URI with a piece of
|
||||
@@ -59,12 +60,16 @@ class PasswordBroker implements PasswordBrokerContract
|
||||
return static::RESET_THROTTLED;
|
||||
}
|
||||
|
||||
// Once we have the reset token, we are ready to send the message out to this
|
||||
// user with a link to reset their password. We will then redirect back to
|
||||
// the current URI having nothing set in the session to indicate errors.
|
||||
$user->sendPasswordResetNotification(
|
||||
$this->tokens->create($user)
|
||||
);
|
||||
$token = $this->tokens->create($user);
|
||||
|
||||
if ($callback) {
|
||||
$callback($user, $token);
|
||||
} else {
|
||||
// Once we have the reset token, we are ready to send the message out to this
|
||||
// user with a link to reset their password. We will then redirect back to
|
||||
// the current URI having nothing set in the session to indicate errors.
|
||||
$user->sendPasswordResetNotification($token);
|
||||
}
|
||||
|
||||
return static::RESET_LINK_SENT;
|
||||
}
|
||||
|
||||
0
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordResetServiceProvider.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordResetServiceProvider.php
vendored
Normal file → Executable file
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
@@ -17,9 +17,12 @@ use Illuminate\Contracts\Auth\UserProvider;
|
||||
use Illuminate\Contracts\Cookie\QueueingFactory as CookieJar;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Contracts\Session\Session;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Timebox;
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
|
||||
@@ -29,7 +32,7 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
use GuardHelpers, Macroable;
|
||||
|
||||
/**
|
||||
* The name of the Guard. Typically "session".
|
||||
* The name of the guard. Typically "web".
|
||||
*
|
||||
* Corresponds to guard name in authentication configuration.
|
||||
*
|
||||
@@ -51,6 +54,13 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
*/
|
||||
protected $viaRemember = false;
|
||||
|
||||
/**
|
||||
* The number of minutes that the "remember me" cookie should be valid for.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $rememberDuration = 2628000;
|
||||
|
||||
/**
|
||||
* The session used by the guard.
|
||||
*
|
||||
@@ -79,6 +89,13 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
*/
|
||||
protected $events;
|
||||
|
||||
/**
|
||||
* The timebox instance.
|
||||
*
|
||||
* @var \Illuminate\Support\Timebox
|
||||
*/
|
||||
protected $timebox;
|
||||
|
||||
/**
|
||||
* Indicates if the logout method has been called.
|
||||
*
|
||||
@@ -100,17 +117,20 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
* @param \Illuminate\Contracts\Auth\UserProvider $provider
|
||||
* @param \Illuminate\Contracts\Session\Session $session
|
||||
* @param \Symfony\Component\HttpFoundation\Request|null $request
|
||||
* @param \Illuminate\Support\Timebox|null $timebox
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name,
|
||||
UserProvider $provider,
|
||||
Session $session,
|
||||
Request $request = null)
|
||||
Request $request = null,
|
||||
Timebox $timebox = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->session = $session;
|
||||
$this->request = $request;
|
||||
$this->provider = $provider;
|
||||
$this->timebox = $timebox ?: new Timebox;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,7 +340,7 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the credential array for a HTTP Basic request.
|
||||
* Get the credential array for an HTTP Basic request.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @param string $field
|
||||
@@ -373,6 +393,34 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to authenticate a user with credentials and additional callbacks.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param array|callable $callbacks
|
||||
* @param false $remember
|
||||
* @return bool
|
||||
*/
|
||||
public function attemptWhen(array $credentials = [], $callbacks = null, $remember = false)
|
||||
{
|
||||
$this->fireAttemptEvent($credentials, $remember);
|
||||
|
||||
$this->lastAttempted = $user = $this->provider->retrieveByCredentials($credentials);
|
||||
|
||||
// This method does the exact same thing as attempt, but also executes callbacks after
|
||||
// the user is retrieved and validated. If one of the callbacks returns falsy we do
|
||||
// not login the user. Instead, we will fail the specific authentication attempt.
|
||||
if ($this->hasValidCredentials($user, $credentials) && $this->shouldLogin($callbacks, $user)) {
|
||||
$this->login($user, $remember);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->fireFailedEvent($user, $credentials);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user matches the credentials.
|
||||
*
|
||||
@@ -382,13 +430,35 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
*/
|
||||
protected function hasValidCredentials($user, $credentials)
|
||||
{
|
||||
$validated = ! is_null($user) && $this->provider->validateCredentials($user, $credentials);
|
||||
return $this->timebox->call(function ($timebox) use ($user, $credentials) {
|
||||
$validated = ! is_null($user) && $this->provider->validateCredentials($user, $credentials);
|
||||
|
||||
if ($validated) {
|
||||
$this->fireValidatedEvent($user);
|
||||
if ($validated) {
|
||||
$timebox->returnEarly();
|
||||
|
||||
$this->fireValidatedEvent($user);
|
||||
}
|
||||
|
||||
return $validated;
|
||||
}, 200 * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user should login by executing the given callbacks.
|
||||
*
|
||||
* @param array|callable|null $callbacks
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return bool
|
||||
*/
|
||||
protected function shouldLogin($callbacks, AuthenticatableContract $user)
|
||||
{
|
||||
foreach (Arr::wrap($callbacks) as $callback) {
|
||||
if (! $callback($user, $this)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $validated;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -484,7 +554,7 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
*/
|
||||
protected function createRecaller($value)
|
||||
{
|
||||
return $this->getCookieJar()->forever($this->getRecallerName(), $value);
|
||||
return $this->getCookieJar()->make($this->getRecallerName(), $value, $this->getRememberDuration());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -517,6 +587,34 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
$this->loggedOut = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the user out of the application on their current device only.
|
||||
*
|
||||
* This method does not cycle the "remember" token.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function logoutCurrentDevice()
|
||||
{
|
||||
$user = $this->user();
|
||||
|
||||
$this->clearUserDataFromStorage();
|
||||
|
||||
// If we have an event dispatcher instance, we can fire off the logout event
|
||||
// so any further processing can be done. This allows the developer to be
|
||||
// listening for anytime a user signs out of this application manually.
|
||||
if (isset($this->events)) {
|
||||
$this->events->dispatch(new CurrentDeviceLogout($this->name, $user));
|
||||
}
|
||||
|
||||
// Once we have fired the logout event we will clear the users out of memory
|
||||
// so they are no longer available as the user is no longer considered as
|
||||
// being signed into this application and should not be available here.
|
||||
$this->user = null;
|
||||
|
||||
$this->loggedOut = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the user data from the session and cookies.
|
||||
*
|
||||
@@ -545,32 +643,6 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
$this->provider->updateRememberToken($user, $token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the user out of the application on their current device only.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function logoutCurrentDevice()
|
||||
{
|
||||
$user = $this->user();
|
||||
|
||||
$this->clearUserDataFromStorage();
|
||||
|
||||
// If we have an event dispatcher instance, we can fire off the logout event
|
||||
// so any further processing can be done. This allows the developer to be
|
||||
// listening for anytime a user signs out of this application manually.
|
||||
if (isset($this->events)) {
|
||||
$this->events->dispatch(new CurrentDeviceLogout($this->name, $user));
|
||||
}
|
||||
|
||||
// Once we have fired the logout event we will clear the users out of memory
|
||||
// so they are no longer available as the user is no longer considered as
|
||||
// being signed into this application and should not be available here.
|
||||
$this->user = null;
|
||||
|
||||
$this->loggedOut = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate other sessions for the current user.
|
||||
*
|
||||
@@ -578,7 +650,9 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
*
|
||||
* @param string $password
|
||||
* @param string $attribute
|
||||
* @return bool|null
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*
|
||||
* @throws \Illuminate\Auth\AuthenticationException
|
||||
*/
|
||||
public function logoutOtherDevices($password, $attribute = 'password')
|
||||
{
|
||||
@@ -586,9 +660,7 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
return;
|
||||
}
|
||||
|
||||
$result = tap($this->user()->forceFill([
|
||||
$attribute => Hash::make($password),
|
||||
]))->save();
|
||||
$result = $this->rehashUserPassword($password, $attribute);
|
||||
|
||||
if ($this->recaller() ||
|
||||
$this->getCookieJar()->hasQueued($this->getRecallerName())) {
|
||||
@@ -600,6 +672,26 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rehash the current user's password.
|
||||
*
|
||||
* @param string $password
|
||||
* @param string $attribute
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function rehashUserPassword($password, $attribute)
|
||||
{
|
||||
if (! Hash::check($password, $this->user()->{$attribute})) {
|
||||
throw new InvalidArgumentException('The given password does not match the current password.');
|
||||
}
|
||||
|
||||
return tap($this->user()->forceFill([
|
||||
$attribute => Hash::make($password),
|
||||
]))->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an authentication attempt event listener.
|
||||
*
|
||||
@@ -746,6 +838,29 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
return $this->viaRemember;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of minutes the remember me cookie should be valid for.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getRememberDuration()
|
||||
{
|
||||
return $this->rememberDuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of minutes the remember me cookie should be valid for.
|
||||
*
|
||||
* @param int $minutes
|
||||
* @return $this
|
||||
*/
|
||||
public function setRememberDuration($minutes)
|
||||
{
|
||||
$this->rememberDuration = $minutes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cookie creator instance used by the guard.
|
||||
*
|
||||
@@ -853,4 +968,14 @@ class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the timebox instance used by the guard.
|
||||
*
|
||||
* @return \Illuminate\Support\Timebox
|
||||
*/
|
||||
public function getTimebox()
|
||||
{
|
||||
return $this->timebox;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,13 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2.5|^8.0",
|
||||
"illuminate/contracts": "^7.0",
|
||||
"illuminate/http": "^7.0",
|
||||
"illuminate/queue": "^7.0",
|
||||
"illuminate/support": "^7.0"
|
||||
"php": "^7.3|^8.0",
|
||||
"illuminate/collections": "^8.0",
|
||||
"illuminate/contracts": "^8.0",
|
||||
"illuminate/http": "^8.0",
|
||||
"illuminate/macroable": "^8.0",
|
||||
"illuminate/queue": "^8.0",
|
||||
"illuminate/support": "^8.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -27,13 +29,13 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "7.x-dev"
|
||||
"dev-master": "8.x-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"illuminate/console": "Required to use the auth:clear-resets command (^7.0).",
|
||||
"illuminate/queue": "Required to fire login / logout events (^7.0).",
|
||||
"illuminate/session": "Required to use the session based guard (^7.0)."
|
||||
"illuminate/console": "Required to use the auth:clear-resets command (^8.0).",
|
||||
"illuminate/queue": "Required to fire login / logout events (^8.0).",
|
||||
"illuminate/session": "Required to use the session based guard (^8.0)."
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Illuminate\Broadcasting;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Broadcasting\Broadcaster;
|
||||
use Illuminate\Contracts\Broadcasting\Factory as BroadcastingFactory;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Support\Arr;
|
||||
@@ -46,23 +46,37 @@ class BroadcastEvent implements ShouldQueue
|
||||
$this->event = $event;
|
||||
$this->tries = property_exists($event, 'tries') ? $event->tries : null;
|
||||
$this->timeout = property_exists($event, 'timeout') ? $event->timeout : null;
|
||||
$this->afterCommit = property_exists($event, 'afterCommit') ? $event->afterCommit : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the queued job.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Broadcasting\Broadcaster $broadcaster
|
||||
* @param \Illuminate\Contracts\Broadcasting\Factory $manager
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Broadcaster $broadcaster)
|
||||
public function handle(BroadcastingFactory $manager)
|
||||
{
|
||||
$name = method_exists($this->event, 'broadcastAs')
|
||||
? $this->event->broadcastAs() : get_class($this->event);
|
||||
|
||||
$broadcaster->broadcast(
|
||||
Arr::wrap($this->event->broadcastOn()), $name,
|
||||
$this->getPayloadFromEvent($this->event)
|
||||
);
|
||||
$channels = Arr::wrap($this->event->broadcastOn());
|
||||
|
||||
if (empty($channels)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$connections = method_exists($this->event, 'broadcastConnections')
|
||||
? $this->event->broadcastConnections()
|
||||
: [null];
|
||||
|
||||
$payload = $this->getPayloadFromEvent($this->event);
|
||||
|
||||
foreach ($connections as $connection) {
|
||||
$manager->connection($connection)->broadcast(
|
||||
$channels, $name, $payload
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,10 +87,9 @@ class BroadcastEvent implements ShouldQueue
|
||||
*/
|
||||
protected function getPayloadFromEvent($event)
|
||||
{
|
||||
if (method_exists($event, 'broadcastWith')) {
|
||||
return array_merge(
|
||||
$event->broadcastWith(), ['socket' => data_get($event, 'socket')]
|
||||
);
|
||||
if (method_exists($event, 'broadcastWith') &&
|
||||
! is_null($payload = $event->broadcastWith())) {
|
||||
return array_merge($payload, ['socket' => data_get($event, 'socket')]);
|
||||
}
|
||||
|
||||
$payload = [];
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Illuminate\Broadcasting;
|
||||
|
||||
use Ably\AblyRest;
|
||||
use Closure;
|
||||
use Illuminate\Broadcasting\Broadcasters\AblyBroadcaster;
|
||||
use Illuminate\Broadcasting\Broadcasters\LogBroadcaster;
|
||||
use Illuminate\Broadcasting\Broadcasters\NullBroadcaster;
|
||||
use Illuminate\Broadcasting\Broadcasters\PusherBroadcaster;
|
||||
@@ -70,7 +72,7 @@ class BroadcastManager implements FactoryContract
|
||||
$router->match(
|
||||
['get', 'post'], '/broadcasting/auth',
|
||||
'\\'.BroadcastController::class.'@authenticate'
|
||||
);
|
||||
)->withoutMiddleware([\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken::class]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -110,7 +112,10 @@ class BroadcastManager implements FactoryContract
|
||||
*/
|
||||
public function queue($event)
|
||||
{
|
||||
if ($event instanceof ShouldBroadcastNow) {
|
||||
if ($event instanceof ShouldBroadcastNow ||
|
||||
(is_object($event) &&
|
||||
method_exists($event, 'shouldBroadcastNow') &&
|
||||
$event->shouldBroadcastNow())) {
|
||||
return $this->app->make(BusDispatcherContract::class)->dispatchNow(new BroadcastEvent(clone $event));
|
||||
}
|
||||
|
||||
@@ -220,6 +225,17 @@ class BroadcastManager implements FactoryContract
|
||||
return new PusherBroadcaster($pusher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Contracts\Broadcasting\Broadcaster
|
||||
*/
|
||||
protected function createAblyDriver(array $config)
|
||||
{
|
||||
return new AblyBroadcaster(new AblyRest($config));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the driver.
|
||||
*
|
||||
@@ -294,6 +310,19 @@ class BroadcastManager implements FactoryContract
|
||||
$this->app['config']['broadcasting.default'] = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect the given disk and remove from local cache.
|
||||
*
|
||||
* @param string|null $name
|
||||
* @return void
|
||||
*/
|
||||
public function purge($name = null)
|
||||
{
|
||||
$name = $name ?? $this->getDefaultDriver();
|
||||
|
||||
unset($this->drivers[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom driver creator Closure.
|
||||
*
|
||||
@@ -308,6 +337,41 @@ class BroadcastManager implements FactoryContract
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the application instance used by the manager.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Foundation\Application
|
||||
*/
|
||||
public function getApplication()
|
||||
{
|
||||
return $this->app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the application instance used by the manager.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
* @return $this
|
||||
*/
|
||||
public function setApplication($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forget all of the resolved driver instances.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function forgetDrivers()
|
||||
{
|
||||
$this->drivers = [];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call the default driver instance.
|
||||
*
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Illuminate\Broadcasting\Broadcasters;
|
||||
use Exception;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Contracts\Broadcasting\Broadcaster as BroadcasterContract;
|
||||
use Illuminate\Contracts\Broadcasting\HasBroadcastChannel;
|
||||
use Illuminate\Contracts\Routing\BindingRegistrar;
|
||||
use Illuminate\Contracts\Routing\UrlRoutable;
|
||||
use Illuminate\Support\Arr;
|
||||
@@ -40,13 +41,19 @@ abstract class Broadcaster implements BroadcasterContract
|
||||
/**
|
||||
* Register a channel authenticator.
|
||||
*
|
||||
* @param string $channel
|
||||
* @param \Illuminate\Contracts\Broadcasting\HasBroadcastChannel|string $channel
|
||||
* @param callable|string $callback
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function channel($channel, $callback, $options = [])
|
||||
{
|
||||
if ($channel instanceof HasBroadcastChannel) {
|
||||
$channel = $channel->broadcastChannelRoute();
|
||||
} elseif (is_string($channel) && class_exists($channel) && is_a($channel, HasBroadcastChannel::class, true)) {
|
||||
$channel = (new $channel)->broadcastChannelRoute();
|
||||
}
|
||||
|
||||
$this->channels[$channel] = $callback;
|
||||
|
||||
$this->channelOptions[$channel] = $options;
|
||||
@@ -317,7 +324,7 @@ abstract class Broadcaster implements BroadcasterContract
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if channel name from request match a pattern from registered channels.
|
||||
* Check if the channel name from the request matches a pattern from registered channels.
|
||||
*
|
||||
* @param string $channel
|
||||
* @param string $pattern
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Illuminate\Broadcasting\Broadcasters;
|
||||
use Illuminate\Broadcasting\BroadcastException;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Pusher\ApiErrorException;
|
||||
use Pusher\Pusher;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
@@ -42,8 +43,9 @@ class PusherBroadcaster extends Broadcaster
|
||||
{
|
||||
$channelName = $this->normalizeChannelName($request->channel_name);
|
||||
|
||||
if ($this->isGuardedChannel($request->channel_name) &&
|
||||
! $this->retrieveUser($request, $channelName)) {
|
||||
if (empty($request->channel_name) ||
|
||||
($this->isGuardedChannel($request->channel_name) &&
|
||||
! $this->retrieveUser($request, $channelName))) {
|
||||
throw new AccessDeniedHttpException;
|
||||
}
|
||||
|
||||
@@ -69,11 +71,17 @@ class PusherBroadcaster extends Broadcaster
|
||||
|
||||
$channelName = $this->normalizeChannelName($request->channel_name);
|
||||
|
||||
$user = $this->retrieveUser($request, $channelName);
|
||||
|
||||
$broadcastIdentifier = method_exists($user, 'getAuthIdentifierForBroadcasting')
|
||||
? $user->getAuthIdentifierForBroadcasting()
|
||||
: $user->getAuthIdentifier();
|
||||
|
||||
return $this->decodePusherResponse(
|
||||
$request,
|
||||
$this->pusher->presence_auth(
|
||||
$request->channel_name, $request->socket_id,
|
||||
$this->retrieveUser($request, $channelName)->getAuthIdentifier(), $result
|
||||
$broadcastIdentifier, $result
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -109,20 +117,44 @@ class PusherBroadcaster extends Broadcaster
|
||||
{
|
||||
$socket = Arr::pull($payload, 'socket');
|
||||
|
||||
$response = $this->pusher->trigger(
|
||||
$this->formatChannels($channels), $event, $payload, $socket, true
|
||||
);
|
||||
if ($this->pusherServerIsVersionFiveOrGreater()) {
|
||||
$parameters = $socket !== null ? ['socket_id' => $socket] : [];
|
||||
|
||||
if ((is_array($response) && $response['status'] >= 200 && $response['status'] <= 299)
|
||||
|| $response === true) {
|
||||
return;
|
||||
try {
|
||||
$this->pusher->trigger(
|
||||
$this->formatChannels($channels), $event, $payload, $parameters
|
||||
);
|
||||
} catch (ApiErrorException $e) {
|
||||
throw new BroadcastException(
|
||||
sprintf('Pusher error: %s.', $e->getMessage())
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$response = $this->pusher->trigger(
|
||||
$this->formatChannels($channels), $event, $payload, $socket, true
|
||||
);
|
||||
|
||||
if ((is_array($response) && $response['status'] >= 200 && $response['status'] <= 299)
|
||||
|| $response === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new BroadcastException(
|
||||
! empty($response['body'])
|
||||
? sprintf('Pusher error: %s.', $response['body'])
|
||||
: 'Failed to connect to Pusher.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
throw new BroadcastException(
|
||||
! empty($response['body'])
|
||||
? sprintf('Pusher error: %s.', $response['body'])
|
||||
: 'Failed to connect to Pusher.'
|
||||
);
|
||||
/**
|
||||
* Determine if the Pusher PHP server is version 5.0 or greater.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function pusherServerIsVersionFiveOrGreater()
|
||||
{
|
||||
return class_exists(ApiErrorException::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,4 +166,15 @@ class PusherBroadcaster extends Broadcaster
|
||||
{
|
||||
return $this->pusher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Pusher SDK instance.
|
||||
*
|
||||
* @param \Pusher\Pusher $pusher
|
||||
* @return void
|
||||
*/
|
||||
public function setPusher($pusher)
|
||||
{
|
||||
$this->pusher = $pusher;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,16 +20,16 @@ class RedisBroadcaster extends Broadcaster
|
||||
/**
|
||||
* The Redis connection to use for broadcasting.
|
||||
*
|
||||
* @var string
|
||||
* @var ?string
|
||||
*/
|
||||
protected $connection;
|
||||
protected $connection = null;
|
||||
|
||||
/**
|
||||
* The Redis key prefix.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $prefix;
|
||||
protected $prefix = '';
|
||||
|
||||
/**
|
||||
* Create a new broadcaster instance.
|
||||
@@ -60,8 +60,9 @@ class RedisBroadcaster extends Broadcaster
|
||||
str_replace($this->prefix, '', $request->channel_name)
|
||||
);
|
||||
|
||||
if ($this->isGuardedChannel($request->channel_name) &&
|
||||
! $this->retrieveUser($request, $channelName)) {
|
||||
if (empty($request->channel_name) ||
|
||||
($this->isGuardedChannel($request->channel_name) &&
|
||||
! $this->retrieveUser($request, $channelName))) {
|
||||
throw new AccessDeniedHttpException;
|
||||
}
|
||||
|
||||
@@ -85,8 +86,14 @@ class RedisBroadcaster extends Broadcaster
|
||||
|
||||
$channelName = $this->normalizeChannelName($request->channel_name);
|
||||
|
||||
$user = $this->retrieveUser($request, $channelName);
|
||||
|
||||
$broadcastIdentifier = method_exists($user, 'getAuthIdentifierForBroadcasting')
|
||||
? $user->getAuthIdentifierForBroadcasting()
|
||||
: $user->getAuthIdentifier();
|
||||
|
||||
return json_encode(['channel_data' => [
|
||||
'user_id' => $this->retrieveUser($request, $channelName)->getAuthIdentifier(),
|
||||
'user_id' => $broadcastIdentifier,
|
||||
'user_info' => $result,
|
||||
]]);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Support\Str;
|
||||
trait UsePusherChannelConventions
|
||||
{
|
||||
/**
|
||||
* Return true if channel is protected by authentication.
|
||||
* Return true if the channel is protected by authentication.
|
||||
*
|
||||
* @param string $channel
|
||||
* @return bool
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Illuminate\Broadcasting;
|
||||
|
||||
use Illuminate\Contracts\Broadcasting\HasBroadcastChannel;
|
||||
|
||||
class Channel
|
||||
{
|
||||
/**
|
||||
@@ -14,12 +16,12 @@ class Channel
|
||||
/**
|
||||
* Create a new channel instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param \Illuminate\Contracts\Broadcasting\HasBroadcastChannel|string $name
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->name = $name instanceof HasBroadcastChannel ? $name->broadcastChannel() : $name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,21 @@ class PendingBroadcast
|
||||
$this->events = $events;
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast the event using a specific broadcaster.
|
||||
*
|
||||
* @param string|null $connection
|
||||
* @return $this
|
||||
*/
|
||||
public function via($connection = null)
|
||||
{
|
||||
if (method_exists($this->event, 'broadcastVia')) {
|
||||
$this->event->broadcastVia($connection);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast the event to everyone except the current user.
|
||||
*
|
||||
|
||||
@@ -2,16 +2,20 @@
|
||||
|
||||
namespace Illuminate\Broadcasting;
|
||||
|
||||
use Illuminate\Contracts\Broadcasting\HasBroadcastChannel;
|
||||
|
||||
class PrivateChannel extends Channel
|
||||
{
|
||||
/**
|
||||
* Create a new channel instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param \Illuminate\Contracts\Broadcasting\HasBroadcastChannel|string $name
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
$name = $name instanceof HasBroadcastChannel ? $name->broadcastChannel() : $name;
|
||||
|
||||
parent::__construct('private-'.$name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,13 +14,14 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2.5|^8.0",
|
||||
"php": "^7.3|^8.0",
|
||||
"ext-json": "*",
|
||||
"psr/log": "^1.0",
|
||||
"illuminate/bus": "^7.0",
|
||||
"illuminate/contracts": "^7.0",
|
||||
"illuminate/queue": "^7.0",
|
||||
"illuminate/support": "^7.0"
|
||||
"psr/log": "^1.0|^2.0",
|
||||
"illuminate/bus": "^8.0",
|
||||
"illuminate/collections": "^8.0",
|
||||
"illuminate/contracts": "^8.0",
|
||||
"illuminate/queue": "^8.0",
|
||||
"illuminate/support": "^8.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -29,11 +30,12 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "7.x-dev"
|
||||
"dev-master": "8.x-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0)."
|
||||
"ably/ably-php": "Required to use the Ably broadcast driver (^1.0).",
|
||||
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0|^5.0|^6.0|^7.0)."
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
|
||||
@@ -23,6 +23,8 @@ class BusServiceProvider extends ServiceProvider implements DeferrableProvider
|
||||
});
|
||||
});
|
||||
|
||||
$this->registerBatchServices();
|
||||
|
||||
$this->app->alias(
|
||||
Dispatcher::class, DispatcherContract::class
|
||||
);
|
||||
@@ -32,6 +34,24 @@ class BusServiceProvider extends ServiceProvider implements DeferrableProvider
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the batch handling services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerBatchServices()
|
||||
{
|
||||
$this->app->singleton(BatchRepository::class, DatabaseBatchRepository::class);
|
||||
|
||||
$this->app->singleton(DatabaseBatchRepository::class, function ($app) {
|
||||
return new DatabaseBatchRepository(
|
||||
$app->make(BatchFactory::class),
|
||||
$app->make('db')->connection($app->config->get('queue.batching.database')),
|
||||
$app->config->get('queue.batching.table', 'job_batches')
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
@@ -43,6 +63,7 @@ class BusServiceProvider extends ServiceProvider implements DeferrableProvider
|
||||
Dispatcher::class,
|
||||
DispatcherContract::class,
|
||||
QueueingDispatcherContract::class,
|
||||
BatchRepository::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,11 @@ use Illuminate\Contracts\Bus\QueueingDispatcher;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Queue\Queue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\PendingChain;
|
||||
use Illuminate\Pipeline\Pipeline;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\Jobs\SyncJob;
|
||||
use Illuminate\Support\Collection;
|
||||
use RuntimeException;
|
||||
|
||||
class Dispatcher implements QueueingDispatcher
|
||||
@@ -69,35 +73,100 @@ class Dispatcher implements QueueingDispatcher
|
||||
*/
|
||||
public function dispatch($command)
|
||||
{
|
||||
if ($this->queueResolver && $this->commandShouldBeQueued($command)) {
|
||||
return $this->dispatchToQueue($command);
|
||||
}
|
||||
|
||||
return $this->dispatchNow($command);
|
||||
return $this->queueResolver && $this->commandShouldBeQueued($command)
|
||||
? $this->dispatchToQueue($command)
|
||||
: $this->dispatchNow($command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a command to its appropriate handler in the current process.
|
||||
*
|
||||
* Queueable jobs will be dispatched to the "sync" queue.
|
||||
*
|
||||
* @param mixed $command
|
||||
* @param mixed $handler
|
||||
* @return mixed
|
||||
*/
|
||||
public function dispatchSync($command, $handler = null)
|
||||
{
|
||||
if ($this->queueResolver &&
|
||||
$this->commandShouldBeQueued($command) &&
|
||||
method_exists($command, 'onConnection')) {
|
||||
return $this->dispatchToQueue($command->onConnection('sync'));
|
||||
}
|
||||
|
||||
return $this->dispatchNow($command, $handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a command to its appropriate handler in the current process without using the synchronous queue.
|
||||
*
|
||||
* @param mixed $command
|
||||
* @param mixed $handler
|
||||
* @return mixed
|
||||
*/
|
||||
public function dispatchNow($command, $handler = null)
|
||||
{
|
||||
$uses = class_uses_recursive($command);
|
||||
|
||||
if (in_array(InteractsWithQueue::class, $uses) &&
|
||||
in_array(Queueable::class, $uses) &&
|
||||
! $command->job) {
|
||||
$command->setJob(new SyncJob($this->container, json_encode([]), 'sync', 'sync'));
|
||||
}
|
||||
|
||||
if ($handler || $handler = $this->getCommandHandler($command)) {
|
||||
$callback = function ($command) use ($handler) {
|
||||
return $handler->handle($command);
|
||||
$method = method_exists($handler, 'handle') ? 'handle' : '__invoke';
|
||||
|
||||
return $handler->{$method}($command);
|
||||
};
|
||||
} else {
|
||||
$callback = function ($command) {
|
||||
return $this->container->call([$command, 'handle']);
|
||||
$method = method_exists($command, 'handle') ? 'handle' : '__invoke';
|
||||
|
||||
return $this->container->call([$command, $method]);
|
||||
};
|
||||
}
|
||||
|
||||
return $this->pipeline->send($command)->through($this->pipes)->then($callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to find the batch with the given ID.
|
||||
*
|
||||
* @param string $batchId
|
||||
* @return \Illuminate\Bus\Batch|null
|
||||
*/
|
||||
public function findBatch(string $batchId)
|
||||
{
|
||||
return $this->container->make(BatchRepository::class)->find($batchId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new batch of queueable jobs.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection|array|mixed $jobs
|
||||
* @return \Illuminate\Bus\PendingBatch
|
||||
*/
|
||||
public function batch($jobs)
|
||||
{
|
||||
return new PendingBatch($this->container, Collection::wrap($jobs));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new chain of queueable jobs.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection|array $jobs
|
||||
* @return \Illuminate\Foundation\Bus\PendingChain
|
||||
*/
|
||||
public function chain($jobs)
|
||||
{
|
||||
$jobs = Collection::wrap($jobs);
|
||||
|
||||
return new PendingChain($jobs->shift(), $jobs->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given command has a handler.
|
||||
*
|
||||
@@ -140,6 +209,8 @@ class Dispatcher implements QueueingDispatcher
|
||||
*
|
||||
* @param mixed $command
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function dispatchToQueue($command)
|
||||
{
|
||||
|
||||
@@ -37,6 +37,13 @@ trait Queueable
|
||||
*/
|
||||
public $chainQueue;
|
||||
|
||||
/**
|
||||
* The callbacks to be executed on chain failure.
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
public $chainCatchCallbacks;
|
||||
|
||||
/**
|
||||
* The number of seconds before the job should be made available.
|
||||
*
|
||||
@@ -44,6 +51,13 @@ trait Queueable
|
||||
*/
|
||||
public $delay;
|
||||
|
||||
/**
|
||||
* Indicates whether the job should be dispatched after all database transactions have committed.
|
||||
*
|
||||
* @var bool|null
|
||||
*/
|
||||
public $afterCommit;
|
||||
|
||||
/**
|
||||
* The middleware the job should be dispatched through.
|
||||
*
|
||||
@@ -125,6 +139,30 @@ trait Queueable
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the job should be dispatched after all database transactions have committed.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function afterCommit()
|
||||
{
|
||||
$this->afterCommit = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the job should not wait until database transactions have been committed before dispatching.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function beforeCommit()
|
||||
{
|
||||
$this->afterCommit = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the middleware the job should be dispatched through.
|
||||
*
|
||||
@@ -158,6 +196,8 @@ trait Queueable
|
||||
*
|
||||
* @param mixed $job
|
||||
* @return string
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function serializeJob($job)
|
||||
{
|
||||
@@ -190,7 +230,21 @@ trait Queueable
|
||||
|
||||
$next->chainConnection = $this->chainConnection;
|
||||
$next->chainQueue = $this->chainQueue;
|
||||
$next->chainCatchCallbacks = $this->chainCatchCallbacks;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke all of the chain's failed job callbacks.
|
||||
*
|
||||
* @param \Throwable $e
|
||||
* @return void
|
||||
*/
|
||||
public function invokeChainCatchCallbacks($e)
|
||||
{
|
||||
collect($this->chainCatchCallbacks)->each(function ($callback) use ($e) {
|
||||
$callback($e);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,11 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2.5|^8.0",
|
||||
"illuminate/contracts": "^7.0",
|
||||
"illuminate/pipeline": "^7.0",
|
||||
"illuminate/support": "^7.0"
|
||||
"php": "^7.3|^8.0",
|
||||
"illuminate/collections": "^8.0",
|
||||
"illuminate/contracts": "^8.0",
|
||||
"illuminate/pipeline": "^8.0",
|
||||
"illuminate/support": "^8.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -26,7 +27,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "7.x-dev"
|
||||
"dev-master": "8.x-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
|
||||
0
vendor/laravel/framework/src/Illuminate/Cache/ApcStore.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Cache/ApcStore.php
vendored
Normal file → Executable file
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
79
vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php
vendored
Normal file → Executable file
79
vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php
vendored
Normal file → Executable file
@@ -199,7 +199,11 @@ class CacheManager implements FactoryContract
|
||||
|
||||
$connection = $config['connection'] ?? 'default';
|
||||
|
||||
return $this->repository(new RedisStore($redis, $this->getPrefix($config), $connection));
|
||||
$store = new RedisStore($redis, $this->getPrefix($config), $connection);
|
||||
|
||||
return $this->repository(
|
||||
$store->setLockConnection($config['lock_connection'] ?? $connection)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,15 +216,17 @@ class CacheManager implements FactoryContract
|
||||
{
|
||||
$connection = $this->app['db']->connection($config['connection'] ?? null);
|
||||
|
||||
return $this->repository(
|
||||
new DatabaseStore(
|
||||
$connection,
|
||||
$config['table'],
|
||||
$this->getPrefix($config),
|
||||
$config['lock_table'] ?? 'cache_locks',
|
||||
$config['lock_lottery'] ?? [2, 100]
|
||||
)
|
||||
$store = new DatabaseStore(
|
||||
$connection,
|
||||
$config['table'],
|
||||
$this->getPrefix($config),
|
||||
$config['lock_table'] ?? 'cache_locks',
|
||||
$config['lock_lottery'] ?? [2, 100]
|
||||
);
|
||||
|
||||
return $this->repository($store->setLockConnection(
|
||||
$this->app['db']->connection($config['lock_connection'] ?? $config['connection'] ?? null)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,21 +237,11 @@ class CacheManager implements FactoryContract
|
||||
*/
|
||||
protected function createDynamodbDriver(array $config)
|
||||
{
|
||||
$dynamoConfig = [
|
||||
'region' => $config['region'],
|
||||
'version' => 'latest',
|
||||
'endpoint' => $config['endpoint'] ?? null,
|
||||
];
|
||||
|
||||
if ($config['key'] && $config['secret']) {
|
||||
$dynamoConfig['credentials'] = Arr::only(
|
||||
$config, ['key', 'secret', 'token']
|
||||
);
|
||||
}
|
||||
$client = $this->newDynamodbClient($config);
|
||||
|
||||
return $this->repository(
|
||||
new DynamoDbStore(
|
||||
new DynamoDbClient($dynamoConfig),
|
||||
$client,
|
||||
$config['table'],
|
||||
$config['attributes']['key'] ?? 'key',
|
||||
$config['attributes']['value'] ?? 'value',
|
||||
@@ -255,6 +251,28 @@ class CacheManager implements FactoryContract
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new DynamoDb Client instance.
|
||||
*
|
||||
* @return DynamoDbClient
|
||||
*/
|
||||
protected function newDynamodbClient(array $config)
|
||||
{
|
||||
$dynamoConfig = [
|
||||
'region' => $config['region'],
|
||||
'version' => 'latest',
|
||||
'endpoint' => $config['endpoint'] ?? null,
|
||||
];
|
||||
|
||||
if (isset($config['key']) && isset($config['secret'])) {
|
||||
$dynamoConfig['credentials'] = Arr::only(
|
||||
$config, ['key', 'secret', 'token']
|
||||
);
|
||||
}
|
||||
|
||||
return new DynamoDbClient($dynamoConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new cache repository with the given implementation.
|
||||
*
|
||||
@@ -314,7 +332,11 @@ class CacheManager implements FactoryContract
|
||||
*/
|
||||
protected function getConfig($name)
|
||||
{
|
||||
return $this->app['config']["cache.stores.{$name}"];
|
||||
if (! is_null($name) && $name !== 'null') {
|
||||
return $this->app['config']["cache.stores.{$name}"];
|
||||
}
|
||||
|
||||
return ['driver' => 'null'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -357,6 +379,19 @@ class CacheManager implements FactoryContract
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect the given driver and remove from local cache.
|
||||
*
|
||||
* @param string|null $name
|
||||
* @return void
|
||||
*/
|
||||
public function purge($name = null)
|
||||
{
|
||||
$name = $name ?? $this->getDefaultDriver();
|
||||
|
||||
unset($this->stores[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom driver creator Closure.
|
||||
*
|
||||
|
||||
8
vendor/laravel/framework/src/Illuminate/Cache/CacheServiceProvider.php
vendored
Normal file → Executable file
8
vendor/laravel/framework/src/Illuminate/Cache/CacheServiceProvider.php
vendored
Normal file → Executable file
@@ -30,6 +30,12 @@ class CacheServiceProvider extends ServiceProvider implements DeferrableProvider
|
||||
$this->app->singleton('memcached.connector', function () {
|
||||
return new MemcachedConnector;
|
||||
});
|
||||
|
||||
$this->app->singleton(RateLimiter::class, function ($app) {
|
||||
return new RateLimiter($app->make('cache')->driver(
|
||||
$app['config']->get('cache.limiter')
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +46,7 @@ class CacheServiceProvider extends ServiceProvider implements DeferrableProvider
|
||||
public function provides()
|
||||
{
|
||||
return [
|
||||
'cache', 'cache.store', 'cache.psr6', 'memcached.connector',
|
||||
'cache', 'cache.store', 'cache.psr6', 'memcached.connector', RateLimiter::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
2
vendor/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php
vendored
Normal file → Executable file
2
vendor/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php
vendored
Normal file → Executable file
@@ -116,7 +116,7 @@ class ClearCommand extends Command
|
||||
*/
|
||||
protected function tags()
|
||||
{
|
||||
return array_filter(explode(',', $this->option('tags')));
|
||||
return array_filter(explode(',', $this->option('tags') ?? ''));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
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
@@ -14,10 +14,16 @@ class CreateCacheTable extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create('cache', function (Blueprint $table) {
|
||||
$table->string('key')->unique();
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,5 +34,6 @@ class CreateCacheTable extends Migration
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,4 +136,14 @@ class DatabaseLock extends Lock
|
||||
{
|
||||
return optional($this->connection->table($this->table)->where('key', $this->name)->first())->owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the database connection being used to manage the lock.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getConnectionName()
|
||||
{
|
||||
return $this->connection->getName();
|
||||
}
|
||||
}
|
||||
|
||||
24
vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php
vendored
Normal file → Executable file
24
vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php
vendored
Normal file → Executable file
@@ -23,6 +23,13 @@ class DatabaseStore implements LockProvider, Store
|
||||
*/
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* The database connection instance that should be used to manage locks.
|
||||
*
|
||||
* @var \Illuminate\Database\ConnectionInterface
|
||||
*/
|
||||
protected $lockConnection;
|
||||
|
||||
/**
|
||||
* The name of the cache table.
|
||||
*
|
||||
@@ -155,8 +162,6 @@ class DatabaseStore implements LockProvider, Store
|
||||
'expiration' => $expiration,
|
||||
]) >= 1;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,7 +272,7 @@ class DatabaseStore implements LockProvider, Store
|
||||
public function lock($name, $seconds = 0, $owner = null)
|
||||
{
|
||||
return new DatabaseLock(
|
||||
$this->connection,
|
||||
$this->lockConnection ?? $this->connection,
|
||||
$this->lockTable,
|
||||
$this->prefix.$name,
|
||||
$seconds,
|
||||
@@ -333,6 +338,19 @@ class DatabaseStore implements LockProvider, Store
|
||||
return $this->connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the name of the connection that should be used to manage locks.
|
||||
*
|
||||
* @param \Illuminate\Database\ConnectionInterface $connection
|
||||
* @return $this
|
||||
*/
|
||||
public function setLockConnection($connection)
|
||||
{
|
||||
$this->lockConnection = $connection;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cache key prefix.
|
||||
*
|
||||
|
||||
@@ -34,9 +34,11 @@ class DynamoDbLock extends Lock
|
||||
*/
|
||||
public function acquire()
|
||||
{
|
||||
return $this->dynamo->add(
|
||||
$this->name, $this->owner, $this->seconds
|
||||
);
|
||||
if ($this->seconds > 0) {
|
||||
return $this->dynamo->add($this->name, $this->owner, $this->seconds);
|
||||
} else {
|
||||
return $this->dynamo->add($this->name, $this->owner, 86400);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -525,4 +525,14 @@ class DynamoDbStore implements LockProvider, Store
|
||||
{
|
||||
$this->prefix = ! empty($prefix) ? $prefix.':' : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DynamoDb Client instance.
|
||||
*
|
||||
* @return DynamoDbClient
|
||||
*/
|
||||
public function getClient()
|
||||
{
|
||||
return $this->dynamo;
|
||||
}
|
||||
}
|
||||
|
||||
62
vendor/laravel/framework/src/Illuminate/Cache/FileStore.php
vendored
Normal file → Executable file
62
vendor/laravel/framework/src/Illuminate/Cache/FileStore.php
vendored
Normal file → Executable file
@@ -3,13 +3,16 @@
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Cache\LockProvider;
|
||||
use Illuminate\Contracts\Cache\Store;
|
||||
use Illuminate\Contracts\Filesystem\LockTimeoutException;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Filesystem\LockableFile;
|
||||
use Illuminate\Support\InteractsWithTime;
|
||||
|
||||
class FileStore implements Store
|
||||
class FileStore implements Store, LockProvider
|
||||
{
|
||||
use InteractsWithTime, RetrievesMultipleKeys;
|
||||
use InteractsWithTime, HasCacheLock, RetrievesMultipleKeys;
|
||||
|
||||
/**
|
||||
* The Illuminate Filesystem instance.
|
||||
@@ -75,7 +78,7 @@ class FileStore implements Store
|
||||
);
|
||||
|
||||
if ($result !== false && $result > 0) {
|
||||
$this->ensureFileHasCorrectPermissions($path);
|
||||
$this->ensurePermissionsAreCorrect($path);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -83,6 +86,45 @@ class FileStore implements Store
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$this->ensureCacheDirectoryExists($path = $this->path($key));
|
||||
|
||||
$file = new LockableFile($path, 'c+');
|
||||
|
||||
try {
|
||||
$file->getExclusiveLock();
|
||||
} catch (LockTimeoutException $e) {
|
||||
$file->close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$expire = $file->read(10);
|
||||
|
||||
if (empty($expire) || $this->currentTime() >= $expire) {
|
||||
$file->truncate()
|
||||
->write($this->expiration($seconds).serialize($value))
|
||||
->close();
|
||||
|
||||
$this->ensurePermissionsAreCorrect($path);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$file->close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the file cache directory if necessary.
|
||||
*
|
||||
@@ -91,18 +133,24 @@ class FileStore implements Store
|
||||
*/
|
||||
protected function ensureCacheDirectoryExists($path)
|
||||
{
|
||||
if (! $this->files->exists(dirname($path))) {
|
||||
$this->files->makeDirectory(dirname($path), 0777, true, true);
|
||||
$directory = dirname($path);
|
||||
|
||||
if (! $this->files->exists($directory)) {
|
||||
$this->files->makeDirectory($directory, 0777, true, true);
|
||||
|
||||
// We're creating two levels of directories (e.g. 7e/24), so we check them both...
|
||||
$this->ensurePermissionsAreCorrect($directory);
|
||||
$this->ensurePermissionsAreCorrect(dirname($directory));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the cache file has the correct permissions.
|
||||
* Ensure the created node has the correct permissions.
|
||||
*
|
||||
* @param string $path
|
||||
* @return void
|
||||
*/
|
||||
protected function ensureFileHasCorrectPermissions($path)
|
||||
protected function ensurePermissionsAreCorrect($path)
|
||||
{
|
||||
if (is_null($this->filePermission) ||
|
||||
intval($this->files->chmod($path), 8) == $this->filePermission) {
|
||||
|
||||
@@ -105,7 +105,7 @@ abstract class Lock implements LockContract
|
||||
*
|
||||
* @param int $seconds
|
||||
* @param callable|null $callback
|
||||
* @return bool
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Cache\LockTimeoutException
|
||||
*/
|
||||
@@ -153,7 +153,7 @@ abstract class Lock implements LockContract
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the number of milliseconds to sleep in between blocked lock aquisition attempts.
|
||||
* Specify the number of milliseconds to sleep in between blocked lock acquisition attempts.
|
||||
*
|
||||
* @param int $milliseconds
|
||||
* @return $this
|
||||
|
||||
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
0
vendor/laravel/framework/src/Illuminate/Cache/MemcachedStore.php
vendored
Normal file → Executable file
0
vendor/laravel/framework/src/Illuminate/Cache/MemcachedStore.php
vendored
Normal file → Executable file
35
vendor/laravel/framework/src/Illuminate/Cache/NullStore.php
vendored
Normal file → Executable file
35
vendor/laravel/framework/src/Illuminate/Cache/NullStore.php
vendored
Normal file → Executable file
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
class NullStore extends TaggableStore
|
||||
use Illuminate\Contracts\Cache\LockProvider;
|
||||
|
||||
class NullStore extends TaggableStore implements LockProvider
|
||||
{
|
||||
use RetrievesMultipleKeys;
|
||||
|
||||
@@ -10,7 +12,7 @@ class NullStore extends TaggableStore
|
||||
* Retrieve an item from the cache by key.
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
* @return void
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
@@ -35,7 +37,7 @@ class NullStore extends TaggableStore
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int|bool
|
||||
* @return bool
|
||||
*/
|
||||
public function increment($key, $value = 1)
|
||||
{
|
||||
@@ -47,7 +49,7 @@ class NullStore extends TaggableStore
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int|bool
|
||||
* @return bool
|
||||
*/
|
||||
public function decrement($key, $value = 1)
|
||||
{
|
||||
@@ -66,6 +68,31 @@ class NullStore extends TaggableStore
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 NoLock($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.
|
||||
*
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Cache\Repository as Cache;
|
||||
use Illuminate\Support\InteractsWithTime;
|
||||
|
||||
@@ -16,6 +17,13 @@ class RateLimiter
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* The configured limit object resolvers.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $limiters = [];
|
||||
|
||||
/**
|
||||
* Create a new rate limiter instance.
|
||||
*
|
||||
@@ -27,6 +35,51 @@ class RateLimiter
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a named limiter configuration.
|
||||
*
|
||||
* @param string $name
|
||||
* @param \Closure $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function for(string $name, Closure $callback)
|
||||
{
|
||||
$this->limiters[$name] = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the given named rate limiter.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \Closure
|
||||
*/
|
||||
public function limiter(string $name)
|
||||
{
|
||||
return $this->limiters[$name] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to execute a callback if it's not limited.
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $maxAttempts
|
||||
* @param \Closure $callback
|
||||
* @param int $decaySeconds
|
||||
* @return mixed
|
||||
*/
|
||||
public function attempt($key, $maxAttempts, Closure $callback, $decaySeconds = 60)
|
||||
{
|
||||
if ($this->tooManyAttempts($key, $maxAttempts)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return tap($callback() ?: true, function () use ($key, $decaySeconds) {
|
||||
$this->hit($key, $decaySeconds);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given key has been "accessed" too many times.
|
||||
*
|
||||
@@ -36,6 +89,8 @@ class RateLimiter
|
||||
*/
|
||||
public function tooManyAttempts($key, $maxAttempts)
|
||||
{
|
||||
$key = $this->cleanRateLimiterKey($key);
|
||||
|
||||
if ($this->attempts($key) >= $maxAttempts) {
|
||||
if ($this->cache->has($key.':timer')) {
|
||||
return true;
|
||||
@@ -56,6 +111,8 @@ class RateLimiter
|
||||
*/
|
||||
public function hit($key, $decaySeconds = 60)
|
||||
{
|
||||
$key = $this->cleanRateLimiterKey($key);
|
||||
|
||||
$this->cache->add(
|
||||
$key.':timer', $this->availableAt($decaySeconds), $decaySeconds
|
||||
);
|
||||
@@ -79,6 +136,8 @@ class RateLimiter
|
||||
*/
|
||||
public function attempts($key)
|
||||
{
|
||||
$key = $this->cleanRateLimiterKey($key);
|
||||
|
||||
return $this->cache->get($key, 0);
|
||||
}
|
||||
|
||||
@@ -90,9 +149,27 @@ class RateLimiter
|
||||
*/
|
||||
public function resetAttempts($key)
|
||||
{
|
||||
$key = $this->cleanRateLimiterKey($key);
|
||||
|
||||
return $this->cache->forget($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of retries left for the given key.
|
||||
*
|
||||
* @param string $key
|
||||
* @param int $maxAttempts
|
||||
* @return int
|
||||
*/
|
||||
public function remaining($key, $maxAttempts)
|
||||
{
|
||||
$key = $this->cleanRateLimiterKey($key);
|
||||
|
||||
$attempts = $this->attempts($key);
|
||||
|
||||
return $maxAttempts - $attempts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of retries left for the given key.
|
||||
*
|
||||
@@ -102,9 +179,7 @@ class RateLimiter
|
||||
*/
|
||||
public function retriesLeft($key, $maxAttempts)
|
||||
{
|
||||
$attempts = $this->attempts($key);
|
||||
|
||||
return $maxAttempts - $attempts;
|
||||
return $this->remaining($key, $maxAttempts);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,6 +190,8 @@ class RateLimiter
|
||||
*/
|
||||
public function clear($key)
|
||||
{
|
||||
$key = $this->cleanRateLimiterKey($key);
|
||||
|
||||
$this->resetAttempts($key);
|
||||
|
||||
$this->cache->forget($key.':timer');
|
||||
@@ -128,6 +205,19 @@ class RateLimiter
|
||||
*/
|
||||
public function availableIn($key)
|
||||
{
|
||||
return $this->cache->get($key.':timer') - $this->currentTime();
|
||||
$key = $this->cleanRateLimiterKey($key);
|
||||
|
||||
return max(0, $this->cache->get($key.':timer') - $this->currentTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean the rate limiter key from unicode characters.
|
||||
*
|
||||
* @param string $key
|
||||
* @return string
|
||||
*/
|
||||
public function cleanRateLimiterKey($key)
|
||||
{
|
||||
return preg_replace('/&([a-z])[a-z]+;/i', '$1', htmlentities($key));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,4 +70,14 @@ class RedisLock extends Lock
|
||||
{
|
||||
return $this->redis->get($this->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the Redis connection being used to manage the lock.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getConnectionName()
|
||||
{
|
||||
return $this->redis->getName();
|
||||
}
|
||||
}
|
||||
|
||||
45
vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php
vendored
Normal file → Executable file
45
vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php
vendored
Normal file → Executable file
@@ -4,6 +4,7 @@ namespace Illuminate\Cache;
|
||||
|
||||
use Illuminate\Contracts\Cache\LockProvider;
|
||||
use Illuminate\Contracts\Redis\Factory as Redis;
|
||||
use Illuminate\Redis\Connections\PhpRedisConnection;
|
||||
|
||||
class RedisStore extends TaggableStore implements LockProvider
|
||||
{
|
||||
@@ -22,12 +23,19 @@ class RedisStore extends TaggableStore implements LockProvider
|
||||
protected $prefix;
|
||||
|
||||
/**
|
||||
* The Redis connection that should be used.
|
||||
* The Redis connection instance that should be used to manage locks.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* The name of the connection that should be used for locks.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $lockConnection;
|
||||
|
||||
/**
|
||||
* Create a new Redis store.
|
||||
*
|
||||
@@ -181,7 +189,15 @@ class RedisStore extends TaggableStore implements LockProvider
|
||||
*/
|
||||
public function lock($name, $seconds = 0, $owner = null)
|
||||
{
|
||||
return new RedisLock($this->connection(), $this->prefix.$name, $seconds, $owner);
|
||||
$lockName = $this->prefix.$name;
|
||||
|
||||
$lockConnection = $this->lockConnection();
|
||||
|
||||
if ($lockConnection instanceof PhpRedisConnection) {
|
||||
return new PhpRedisLock($lockConnection, $lockName, $seconds, $owner);
|
||||
}
|
||||
|
||||
return new RedisLock($lockConnection, $lockName, $seconds, $owner);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,7 +259,17 @@ class RedisStore extends TaggableStore implements LockProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the connection name to be used.
|
||||
* Get the Redis connection instance that should be used to manage locks.
|
||||
*
|
||||
* @return \Illuminate\Redis\Connections\Connection
|
||||
*/
|
||||
public function lockConnection()
|
||||
{
|
||||
return $this->redis->connection($this->lockConnection ?? $this->connection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the name of the connection that should be used to store data.
|
||||
*
|
||||
* @param string $connection
|
||||
* @return void
|
||||
@@ -253,6 +279,19 @@ class RedisStore extends TaggableStore implements LockProvider
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the name of the connection that should be used to manage locks.
|
||||
*
|
||||
* @param string $connection
|
||||
* @return $this
|
||||
*/
|
||||
public function setLockConnection($connection)
|
||||
{
|
||||
$this->lockConnection = $connection;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Redis database instance.
|
||||
*
|
||||
|
||||
@@ -10,6 +10,7 @@ class RedisTaggedCache extends TaggedCache
|
||||
* @var string
|
||||
*/
|
||||
const REFERENCE_KEY_FOREVER = 'forever_ref';
|
||||
|
||||
/**
|
||||
* Standard reference key.
|
||||
*
|
||||
@@ -41,13 +42,13 @@ class RedisTaggedCache extends TaggedCache
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @return int|bool
|
||||
*/
|
||||
public function increment($key, $value = 1)
|
||||
{
|
||||
$this->pushStandardKeys($this->tags->getNamespace(), $key);
|
||||
|
||||
parent::increment($key, $value);
|
||||
return parent::increment($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,13 +56,13 @@ class RedisTaggedCache extends TaggedCache
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @return int|bool
|
||||
*/
|
||||
public function decrement($key, $value = 1)
|
||||
{
|
||||
$this->pushStandardKeys($this->tags->getNamespace(), $key);
|
||||
|
||||
parent::decrement($key, $value);
|
||||
return parent::decrement($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +89,9 @@ class RedisTaggedCache extends TaggedCache
|
||||
$this->deleteForeverKeys();
|
||||
$this->deleteStandardKeys();
|
||||
|
||||
return parent::flush();
|
||||
$this->tags->flush();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,13 +178,26 @@ class RedisTaggedCache extends TaggedCache
|
||||
*/
|
||||
protected function deleteValues($referenceKey)
|
||||
{
|
||||
$values = array_unique($this->store->connection()->smembers($referenceKey));
|
||||
$cursor = $defaultCursorValue = '0';
|
||||
|
||||
if (count($values) > 0) {
|
||||
foreach (array_chunk($values, 1000) as $valuesChunk) {
|
||||
do {
|
||||
[$cursor, $valuesChunk] = $this->store->connection()->sscan(
|
||||
$referenceKey, $cursor, ['match' => '*', 'count' => 1000]
|
||||
);
|
||||
|
||||
// PhpRedis client returns false if set does not exist or empty. Array destruction
|
||||
// on false stores null in each variable. If valuesChunk is null, it means that
|
||||
// there were not results from the previously executed "sscan" Redis command.
|
||||
if (is_null($valuesChunk)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$valuesChunk = array_unique($valuesChunk);
|
||||
|
||||
if (count($valuesChunk) > 0) {
|
||||
$this->store->connection()->del(...$valuesChunk);
|
||||
}
|
||||
}
|
||||
} while (((string) $cursor) !== $defaultCursorValue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
78
vendor/laravel/framework/src/Illuminate/Cache/Repository.php
vendored
Normal file → Executable file
78
vendor/laravel/framework/src/Illuminate/Cache/Repository.php
vendored
Normal file → Executable file
@@ -131,6 +131,8 @@ class Repository implements ArrayAccess, CacheContract
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return iterable
|
||||
*/
|
||||
public function getMultiple($keys, $default = null)
|
||||
{
|
||||
@@ -219,6 +221,8 @@ class Repository implements ArrayAccess, CacheContract
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function set($key, $value, $ttl = null)
|
||||
{
|
||||
@@ -276,6 +280,8 @@ class Repository implements ArrayAccess, CacheContract
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setMultiple($values, $ttl = null)
|
||||
{
|
||||
@@ -292,8 +298,12 @@ class Repository implements ArrayAccess, CacheContract
|
||||
*/
|
||||
public function add($key, $value, $ttl = null)
|
||||
{
|
||||
$seconds = null;
|
||||
|
||||
if ($ttl !== null) {
|
||||
if ($this->getSeconds($ttl) <= 0) {
|
||||
$seconds = $this->getSeconds($ttl);
|
||||
|
||||
if ($seconds <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -301,8 +311,6 @@ class Repository implements ArrayAccess, CacheContract
|
||||
// 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
|
||||
);
|
||||
@@ -313,7 +321,7 @@ class Repository implements ArrayAccess, CacheContract
|
||||
// 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))) {
|
||||
return $this->put($key, $value, $ttl);
|
||||
return $this->put($key, $value, $seconds);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -365,7 +373,7 @@ class Repository implements ArrayAccess, CacheContract
|
||||
* Get an item from the cache, or execute the given Closure and store the result.
|
||||
*
|
||||
* @param string $key
|
||||
* @param \DateTimeInterface|\DateInterval|int|null $ttl
|
||||
* @param \Closure|\DateTimeInterface|\DateInterval|int|null $ttl
|
||||
* @param \Closure $callback
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -380,7 +388,7 @@ class Repository implements ArrayAccess, CacheContract
|
||||
return $value;
|
||||
}
|
||||
|
||||
$this->put($key, $value = $callback(), $ttl);
|
||||
$this->put($key, $value = $callback(), value($ttl));
|
||||
|
||||
return $value;
|
||||
}
|
||||
@@ -437,6 +445,8 @@ class Repository implements ArrayAccess, CacheContract
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($key)
|
||||
{
|
||||
@@ -445,6 +455,8 @@ class Repository implements ArrayAccess, CacheContract
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteMultiple($keys)
|
||||
{
|
||||
@@ -461,6 +473,8 @@ class Repository implements ArrayAccess, CacheContract
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
@@ -477,7 +491,7 @@ class Repository implements ArrayAccess, CacheContract
|
||||
*/
|
||||
public function tags($names)
|
||||
{
|
||||
if (! method_exists($this->store, 'tags')) {
|
||||
if (! $this->supportsTags()) {
|
||||
throw new BadMethodCallException('This cache store does not support tagging.');
|
||||
}
|
||||
|
||||
@@ -501,6 +515,33 @@ class Repository implements ArrayAccess, CacheContract
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the number of seconds for the given TTL.
|
||||
*
|
||||
* @param \DateTimeInterface|\DateInterval|int $ttl
|
||||
* @return int
|
||||
*/
|
||||
protected function getSeconds($ttl)
|
||||
{
|
||||
$duration = $this->parseDateInterval($ttl);
|
||||
|
||||
if ($duration instanceof DateTimeInterface) {
|
||||
$duration = Carbon::now()->diffInRealSeconds($duration, false);
|
||||
}
|
||||
|
||||
return (int) ($duration > 0 ? $duration : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the current store supports tags.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function supportsTags()
|
||||
{
|
||||
return method_exists($this->store, 'tags');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default cache time.
|
||||
*
|
||||
@@ -537,7 +578,7 @@ class Repository implements ArrayAccess, CacheContract
|
||||
/**
|
||||
* Fire an event for this cache instance.
|
||||
*
|
||||
* @param string $event
|
||||
* @param object|string $event
|
||||
* @return void
|
||||
*/
|
||||
protected function event($event)
|
||||
@@ -574,6 +615,7 @@ class Repository implements ArrayAccess, CacheContract
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($key)
|
||||
{
|
||||
return $this->has($key);
|
||||
@@ -585,6 +627,7 @@ class Repository implements ArrayAccess, CacheContract
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($key)
|
||||
{
|
||||
return $this->get($key);
|
||||
@@ -597,6 +640,7 @@ class Repository implements ArrayAccess, CacheContract
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($key, $value)
|
||||
{
|
||||
$this->put($key, $value, $this->default);
|
||||
@@ -608,28 +652,12 @@ class Repository implements ArrayAccess, CacheContract
|
||||
* @param string $key
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($key)
|
||||
{
|
||||
$this->forget($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the number of seconds for the given TTL.
|
||||
*
|
||||
* @param \DateTimeInterface|\DateInterval|int $ttl
|
||||
* @return int
|
||||
*/
|
||||
protected function getSeconds($ttl)
|
||||
{
|
||||
$duration = $this->parseDateInterval($ttl);
|
||||
|
||||
if ($duration instanceof DateTimeInterface) {
|
||||
$duration = Carbon::now()->diffInRealSeconds($duration, false);
|
||||
}
|
||||
|
||||
return (int) $duration > 0 ? $duration : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle dynamic calls into macros or pass missing methods to the store.
|
||||
*
|
||||
|
||||
@@ -16,8 +16,12 @@ trait RetrievesMultipleKeys
|
||||
{
|
||||
$return = [];
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$return[$key] = $this->get($key);
|
||||
$keys = collect($keys)->mapWithKeys(function ($value, $key) {
|
||||
return [is_string($key) ? $key : $value => is_string($key) ? $value : null];
|
||||
})->all();
|
||||
|
||||
foreach ($keys as $key => $default) {
|
||||
$return[$key] = $this->get($key, $default);
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
@@ -56,6 +56,26 @@ class TagSet
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush all the tags in the set.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
array_walk($this->names, [$this, 'flushTag']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the tag from the cache.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function flushTag($name)
|
||||
{
|
||||
$this->store->forget($this->tagKey($name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a unique namespace that changes when any of the tags are flushed.
|
||||
*
|
||||
|
||||
@@ -52,11 +52,11 @@ class TaggedCache extends Repository
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @return int|bool
|
||||
*/
|
||||
public function increment($key, $value = 1)
|
||||
{
|
||||
$this->store->increment($this->itemKey($key), $value);
|
||||
return $this->store->increment($this->itemKey($key), $value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,11 +64,11 @@ class TaggedCache extends Repository
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
* @return int|bool
|
||||
*/
|
||||
public function decrement($key, $value = 1)
|
||||
{
|
||||
$this->store->decrement($this->itemKey($key), $value);
|
||||
return $this->store->decrement($this->itemKey($key), $value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,7 +105,7 @@ class TaggedCache extends Repository
|
||||
/**
|
||||
* Fire an event for this cache instance.
|
||||
*
|
||||
* @param string $event
|
||||
* @param \Illuminate\Cache\Events\CacheEvent $event
|
||||
* @return void
|
||||
*/
|
||||
protected function event($event)
|
||||
|
||||
21
vendor/laravel/framework/src/Illuminate/Cache/composer.json
vendored
Normal file → Executable file
21
vendor/laravel/framework/src/Illuminate/Cache/composer.json
vendored
Normal file → Executable file
@@ -14,9 +14,14 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2.5|^8.0",
|
||||
"illuminate/contracts": "^7.0",
|
||||
"illuminate/support": "^7.0"
|
||||
"php": "^7.3|^8.0",
|
||||
"illuminate/collections": "^8.0",
|
||||
"illuminate/contracts": "^8.0",
|
||||
"illuminate/macroable": "^8.0",
|
||||
"illuminate/support": "^8.0"
|
||||
},
|
||||
"provide": {
|
||||
"psr/simple-cache-implementation": "1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -25,15 +30,15 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "7.x-dev"
|
||||
"dev-master": "8.x-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"ext-memcached": "Required to use the memcache cache driver.",
|
||||
"illuminate/database": "Required to use the database cache driver (^7.0).",
|
||||
"illuminate/filesystem": "Required to use the file cache driver (^7.0).",
|
||||
"illuminate/redis": "Required to use the redis cache driver (^7.0).",
|
||||
"symfony/cache": "Required to PSR-6 cache bridge (^5.0)."
|
||||
"illuminate/database": "Required to use the database cache driver (^8.0).",
|
||||
"illuminate/filesystem": "Required to use the file cache driver (^8.0).",
|
||||
"illuminate/redis": "Required to use the redis cache driver (^8.0).",
|
||||
"symfony/cache": "Required to PSR-6 cache bridge (^5.4)."
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
|
||||
@@ -99,7 +99,7 @@ class Repository implements ArrayAccess, ConfigContract
|
||||
*/
|
||||
public function prepend($key, $value)
|
||||
{
|
||||
$array = $this->get($key);
|
||||
$array = $this->get($key, []);
|
||||
|
||||
array_unshift($array, $value);
|
||||
|
||||
@@ -115,7 +115,7 @@ class Repository implements ArrayAccess, ConfigContract
|
||||
*/
|
||||
public function push($key, $value)
|
||||
{
|
||||
$array = $this->get($key);
|
||||
$array = $this->get($key, []);
|
||||
|
||||
$array[] = $value;
|
||||
|
||||
@@ -138,6 +138,7 @@ class Repository implements ArrayAccess, ConfigContract
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($key)
|
||||
{
|
||||
return $this->has($key);
|
||||
@@ -149,6 +150,7 @@ class Repository implements ArrayAccess, ConfigContract
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($key)
|
||||
{
|
||||
return $this->get($key);
|
||||
@@ -161,6 +163,7 @@ class Repository implements ArrayAccess, ConfigContract
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($key, $value)
|
||||
{
|
||||
$this->set($key, $value);
|
||||
@@ -172,6 +175,7 @@ class Repository implements ArrayAccess, ConfigContract
|
||||
* @param string $key
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($key)
|
||||
{
|
||||
$this->set($key, null);
|
||||
|
||||
8
vendor/laravel/framework/src/Illuminate/Config/composer.json
vendored
Normal file → Executable file
8
vendor/laravel/framework/src/Illuminate/Config/composer.json
vendored
Normal file → Executable file
@@ -14,9 +14,9 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2.5|^8.0",
|
||||
"illuminate/contracts": "^7.0",
|
||||
"illuminate/support": "^7.0"
|
||||
"php": "^7.3|^8.0",
|
||||
"illuminate/collections": "^8.0",
|
||||
"illuminate/contracts": "^8.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -25,7 +25,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "7.x-dev"
|
||||
"dev-master": "8.x-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
||||
9
vendor/laravel/framework/src/Illuminate/Console/Application.php
vendored
Normal file → Executable file
9
vendor/laravel/framework/src/Illuminate/Console/Application.php
vendored
Normal file → Executable file
@@ -19,7 +19,6 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Process\PhpExecutableFinder;
|
||||
|
||||
@@ -77,6 +76,8 @@ class Application extends SymfonyApplication implements ApplicationContract
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function run(InputInterface $input = null, OutputInterface $output = null)
|
||||
{
|
||||
@@ -86,7 +87,7 @@ class Application extends SymfonyApplication implements ApplicationContract
|
||||
|
||||
$this->events->dispatch(
|
||||
new CommandStarting(
|
||||
$commandName, $input, $output = $output ?: new ConsoleOutput
|
||||
$commandName, $input, $output = $output ?: new BufferedConsoleOutput
|
||||
)
|
||||
);
|
||||
|
||||
@@ -116,7 +117,7 @@ class Application extends SymfonyApplication implements ApplicationContract
|
||||
*/
|
||||
public static function artisanBinary()
|
||||
{
|
||||
return defined('ARTISAN_BINARY') ? ProcessUtils::escapeArgument(ARTISAN_BINARY) : 'artisan';
|
||||
return ProcessUtils::escapeArgument(defined('ARTISAN_BINARY') ? ARTISAN_BINARY : 'artisan');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,7 +210,7 @@ class Application extends SymfonyApplication implements ApplicationContract
|
||||
$input = new ArrayInput($parameters);
|
||||
}
|
||||
|
||||
return [$command, $input ?? null];
|
||||
return [$command, $input];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
12
vendor/laravel/framework/src/Illuminate/Console/Command.php
vendored
Normal file → Executable file
12
vendor/laravel/framework/src/Illuminate/Console/Command.php
vendored
Normal file → Executable file
@@ -38,14 +38,14 @@ class Command extends SymfonyCommand
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string|null
|
||||
* @var string
|
||||
*/
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* The console command help text.
|
||||
*
|
||||
* @var string|null
|
||||
* @var string
|
||||
*/
|
||||
protected $help;
|
||||
|
||||
@@ -131,7 +131,9 @@ class Command extends SymfonyCommand
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
return (int) $this->laravel->call([$this, 'handle']);
|
||||
$method = method_exists($this, 'handle') ? 'handle' : '__invoke';
|
||||
|
||||
return (int) $this->laravel->call([$this, $method]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,6 +163,8 @@ class Command extends SymfonyCommand
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
@@ -169,6 +173,8 @@ class Command extends SymfonyCommand
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setHidden(bool $hidden)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ trait CallsCommands
|
||||
}
|
||||
|
||||
/**
|
||||
* Call another console command silently.
|
||||
* Call another console command without output.
|
||||
*
|
||||
* @param \Symfony\Component\Console\Command\Command|string $command
|
||||
* @param array $arguments
|
||||
@@ -40,6 +40,18 @@ trait CallsCommands
|
||||
return $this->runCommand($command, $arguments, new NullOutput);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call another console command without output.
|
||||
*
|
||||
* @param \Symfony\Component\Console\Command\Command|string $command
|
||||
* @param array $arguments
|
||||
* @return int
|
||||
*/
|
||||
public function callSilently($command, array $arguments = [])
|
||||
{
|
||||
return $this->callSilent($command, $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the given the console command.
|
||||
*
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Illuminate\Console\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Console\OutputStyle;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -237,6 +238,38 @@ trait InteractsWithIO
|
||||
$table->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a given callback while advancing a progress bar.
|
||||
*
|
||||
* @param iterable|int $totalSteps
|
||||
* @param \Closure $callback
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function withProgressBar($totalSteps, Closure $callback)
|
||||
{
|
||||
$bar = $this->output->createProgressBar(
|
||||
is_iterable($totalSteps) ? count($totalSteps) : $totalSteps
|
||||
);
|
||||
|
||||
$bar->start();
|
||||
|
||||
if (is_iterable($totalSteps)) {
|
||||
foreach ($totalSteps as $value) {
|
||||
$callback($value, $bar);
|
||||
|
||||
$bar->advance();
|
||||
}
|
||||
} else {
|
||||
$callback($bar);
|
||||
}
|
||||
|
||||
$bar->finish();
|
||||
|
||||
if (is_iterable($totalSteps)) {
|
||||
return $totalSteps;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a string as information output.
|
||||
*
|
||||
@@ -332,7 +365,18 @@ trait InteractsWithIO
|
||||
$this->comment('* '.$string.' *');
|
||||
$this->comment(str_repeat('*', $length));
|
||||
|
||||
$this->output->newLine();
|
||||
$this->newLine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a blank line.
|
||||
*
|
||||
* @param int $count
|
||||
* @return void
|
||||
*/
|
||||
public function newLine($count = 1)
|
||||
{
|
||||
$this->output->newLine($count);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,7 @@ class ScheduledTaskFailed
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Event $task
|
||||
* @param \Throwable $exception
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Event $task, Throwable $exception)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Illuminate\Console;
|
||||
|
||||
use Illuminate\Console\Concerns\CreatesMatchingTest;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
@@ -25,7 +26,7 @@ abstract class GeneratorCommand extends Command
|
||||
/**
|
||||
* Reserved names that cannot be used for generation.
|
||||
*
|
||||
* @var array
|
||||
* @var string[]
|
||||
*/
|
||||
protected $reservedNames = [
|
||||
'__halt_compiler',
|
||||
@@ -108,6 +109,10 @@ abstract class GeneratorCommand extends Command
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if (in_array(CreatesMatchingTest::class, class_uses_recursive($this))) {
|
||||
$this->addTestOptions();
|
||||
}
|
||||
|
||||
$this->files = $files;
|
||||
}
|
||||
|
||||
@@ -159,6 +164,10 @@ abstract class GeneratorCommand extends Command
|
||||
$this->files->put($path, $this->sortImports($this->buildClass($name)));
|
||||
|
||||
$this->info($this->type.' created successfully.');
|
||||
|
||||
if (in_array(CreatesMatchingTest::class, class_uses_recursive($this))) {
|
||||
$this->handleTestCreation($path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,19 +180,42 @@ abstract class GeneratorCommand extends Command
|
||||
{
|
||||
$name = ltrim($name, '\\/');
|
||||
|
||||
$name = str_replace('/', '\\', $name);
|
||||
|
||||
$rootNamespace = $this->rootNamespace();
|
||||
|
||||
if (Str::startsWith($name, $rootNamespace)) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
$name = str_replace('/', '\\', $name);
|
||||
|
||||
return $this->qualifyClass(
|
||||
$this->getDefaultNamespace(trim($rootNamespace, '\\')).'\\'.$name
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Qualify the given model class base name.
|
||||
*
|
||||
* @param string $model
|
||||
* @return string
|
||||
*/
|
||||
protected function qualifyModel(string $model)
|
||||
{
|
||||
$model = ltrim($model, '\\/');
|
||||
|
||||
$model = str_replace('/', '\\', $model);
|
||||
|
||||
$rootNamespace = $this->rootNamespace();
|
||||
|
||||
if (Str::startsWith($model, $rootNamespace)) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
return is_dir(app_path('Models'))
|
||||
? $rootNamespace.'Models\\'.$model
|
||||
: $rootNamespace.$model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default namespace for the class.
|
||||
*
|
||||
|
||||
@@ -68,4 +68,14 @@ class OutputStyle extends SymfonyStyle
|
||||
{
|
||||
return $this->output->isDebug();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying Symfony output implementation.
|
||||
*
|
||||
* @return \Symfony\Component\Console\Output\OutputInterface
|
||||
*/
|
||||
public function getOutput()
|
||||
{
|
||||
return $this->output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Support\Reflector;
|
||||
use InvalidArgumentException;
|
||||
use LogicException;
|
||||
use Throwable;
|
||||
|
||||
class CallbackEvent extends Event
|
||||
{
|
||||
@@ -77,6 +78,12 @@ class CallbackEvent extends Event
|
||||
$response = is_object($this->callback)
|
||||
? $container->call([$this->callback, '__invoke'], $this->parameters)
|
||||
: $container->call($this->callback, $this->parameters);
|
||||
|
||||
$this->exitCode = $response === false ? 1 : 0;
|
||||
} catch (Throwable $e) {
|
||||
$this->exitCode = 1;
|
||||
|
||||
throw $e;
|
||||
} finally {
|
||||
$this->removeMutex();
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class CommandBuilder
|
||||
$finished = Application::formatCommandString('schedule:finish').' "'.$event->mutexName().'"';
|
||||
|
||||
if (windows_os()) {
|
||||
return 'start /b cmd /c "('.$event->command.' & '.$finished.' "%errorlevel%")'.$redirect.$output.' 2>&1"';
|
||||
return 'start /b cmd /v:on /c "('.$event->command.' & '.$finished.' ^!ERRORLEVEL^!)'.$redirect.$output.' 2>&1"';
|
||||
}
|
||||
|
||||
return $this->ensureCorrectUser($event,
|
||||
|
||||
@@ -10,13 +10,14 @@ use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Debug\ExceptionHandler;
|
||||
use Illuminate\Contracts\Mail\Mailer;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Illuminate\Support\Reflector;
|
||||
use Illuminate\Support\Stringable;
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
use Illuminate\Support\Traits\ReflectsClosures;
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Throwable;
|
||||
|
||||
class Event
|
||||
{
|
||||
@@ -86,7 +87,7 @@ class Event
|
||||
public $expiresAt = 1440;
|
||||
|
||||
/**
|
||||
* Indicates if the command should run in background.
|
||||
* Indicates if the command should run in the background.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
@@ -218,11 +219,17 @@ class Event
|
||||
*/
|
||||
protected function runCommandInForeground(Container $container)
|
||||
{
|
||||
$this->callBeforeCallbacks($container);
|
||||
try {
|
||||
$this->callBeforeCallbacks($container);
|
||||
|
||||
$this->exitCode = Process::fromShellCommandline($this->buildCommand(), base_path(), null, null, null)->run();
|
||||
$this->exitCode = Process::fromShellCommandline(
|
||||
$this->buildCommand(), base_path(), null, null, null
|
||||
)->run();
|
||||
|
||||
$this->callAfterCallbacks($container);
|
||||
$this->callAfterCallbacks($container);
|
||||
} finally {
|
||||
$this->removeMutex();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,9 +240,15 @@ class Event
|
||||
*/
|
||||
protected function runCommandInBackground(Container $container)
|
||||
{
|
||||
$this->callBeforeCallbacks($container);
|
||||
try {
|
||||
$this->callBeforeCallbacks($container);
|
||||
|
||||
Process::fromShellCommandline($this->buildCommand(), base_path(), null, null, null)->run();
|
||||
Process::fromShellCommandline($this->buildCommand(), base_path(), null, null, null)->run();
|
||||
} catch (Throwable $exception) {
|
||||
$this->removeMutex();
|
||||
|
||||
throw $exception;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -275,7 +288,11 @@ class Event
|
||||
{
|
||||
$this->exitCode = (int) $exitCode;
|
||||
|
||||
$this->callAfterCallbacks($container);
|
||||
try {
|
||||
$this->callAfterCallbacks($container);
|
||||
} finally {
|
||||
$this->removeMutex();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,13 +338,13 @@ class Event
|
||||
*/
|
||||
protected function expressionPasses()
|
||||
{
|
||||
$date = Carbon::now();
|
||||
$date = Date::now();
|
||||
|
||||
if ($this->timezone) {
|
||||
$date->setTimezone($this->timezone);
|
||||
$date = $date->setTimezone($this->timezone);
|
||||
}
|
||||
|
||||
return CronExpression::factory($this->expression)->isDue($date->toDateTimeString());
|
||||
return (new CronExpression($this->expression))->isDue($date->toDateTimeString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -475,7 +492,7 @@ class Event
|
||||
*/
|
||||
protected function emailOutput(Mailer $mailer, $addresses, $onlyIfOutputExists = false)
|
||||
{
|
||||
$text = file_exists($this->output) ? file_get_contents($this->output) : '';
|
||||
$text = is_file($this->output) ? file_get_contents($this->output) : '';
|
||||
|
||||
if ($onlyIfOutputExists && empty($text)) {
|
||||
return;
|
||||
@@ -586,7 +603,7 @@ class Event
|
||||
}
|
||||
|
||||
/**
|
||||
* State that the command should run in background.
|
||||
* State that the command should run in the background.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
@@ -647,9 +664,7 @@ class Event
|
||||
|
||||
$this->expiresAt = $expiresAt;
|
||||
|
||||
return $this->then(function () {
|
||||
$this->mutex->forget($this);
|
||||
})->skip(function () {
|
||||
return $this->skip(function () {
|
||||
return $this->mutex->exists($this);
|
||||
});
|
||||
}
|
||||
@@ -728,6 +743,12 @@ class Event
|
||||
*/
|
||||
public function then(Closure $callback)
|
||||
{
|
||||
$parameters = $this->closureParameterTypes($callback);
|
||||
|
||||
if (Arr::get($parameters, 'output') === Stringable::class) {
|
||||
return $this->thenWithOutput($callback);
|
||||
}
|
||||
|
||||
$this->afterCallbacks[] = $callback;
|
||||
|
||||
return $this;
|
||||
@@ -755,6 +776,12 @@ class Event
|
||||
*/
|
||||
public function onSuccess(Closure $callback)
|
||||
{
|
||||
$parameters = $this->closureParameterTypes($callback);
|
||||
|
||||
if (Arr::get($parameters, 'output') === Stringable::class) {
|
||||
return $this->onSuccessWithOutput($callback);
|
||||
}
|
||||
|
||||
return $this->then(function (Container $container) use ($callback) {
|
||||
if (0 === $this->exitCode) {
|
||||
$container->call($callback);
|
||||
@@ -784,6 +811,12 @@ class Event
|
||||
*/
|
||||
public function onFailure(Closure $callback)
|
||||
{
|
||||
$parameters = $this->closureParameterTypes($callback);
|
||||
|
||||
if (Arr::get($parameters, 'output') === Stringable::class) {
|
||||
return $this->onFailureWithOutput($callback);
|
||||
}
|
||||
|
||||
return $this->then(function (Container $container) use ($callback) {
|
||||
if (0 !== $this->exitCode) {
|
||||
$container->call($callback);
|
||||
@@ -815,11 +848,11 @@ class Event
|
||||
protected function withOutputCallback(Closure $callback, $onlyIfOutputExists = false)
|
||||
{
|
||||
return function (Container $container) use ($callback, $onlyIfOutputExists) {
|
||||
$output = $this->output && file_exists($this->output) ? file_get_contents($this->output) : '';
|
||||
$output = $this->output && is_file($this->output) ? file_get_contents($this->output) : '';
|
||||
|
||||
return $onlyIfOutputExists && empty($output)
|
||||
? null
|
||||
: $container->call($callback, ['output' => $output]);
|
||||
: $container->call($callback, ['output' => new Stringable($output)]);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -871,9 +904,8 @@ class Event
|
||||
*/
|
||||
public function nextRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false)
|
||||
{
|
||||
return Date::instance(CronExpression::factory(
|
||||
$this->getExpression()
|
||||
)->getNextRunDate($currentTime, $nth, $allowCurrentDate, $this->timezone));
|
||||
return Date::instance((new CronExpression($this->getExpression()))
|
||||
->getNextRunDate($currentTime, $nth, $allowCurrentDate, $this->timezone));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -898,4 +930,16 @@ class Event
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the mutex for the event.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function removeMutex()
|
||||
{
|
||||
if ($this->withoutOverlapping) {
|
||||
$this->mutex->forget($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,10 +262,23 @@ trait ManagesFrequencies
|
||||
* @return $this
|
||||
*/
|
||||
public function twiceDaily($first = 1, $second = 13)
|
||||
{
|
||||
return $this->twiceDailyAt($first, $second, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule the event to run twice daily at a given offset.
|
||||
*
|
||||
* @param int $first
|
||||
* @param int $second
|
||||
* @param int $offset
|
||||
* @return $this
|
||||
*/
|
||||
public function twiceDailyAt($first = 1, $second = 13, $offset = 0)
|
||||
{
|
||||
$hours = $first.','.$second;
|
||||
|
||||
return $this->spliceIntoPosition(1, 0)
|
||||
return $this->spliceIntoPosition(1, $offset)
|
||||
->spliceIntoPosition(2, $hours);
|
||||
}
|
||||
|
||||
@@ -276,7 +289,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function weekdays()
|
||||
{
|
||||
return $this->spliceIntoPosition(5, '1-5');
|
||||
return $this->days(Schedule::MONDAY.'-'.Schedule::FRIDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,7 +299,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function weekends()
|
||||
{
|
||||
return $this->spliceIntoPosition(5, '0,6');
|
||||
return $this->days(Schedule::SATURDAY.','.Schedule::SUNDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,7 +309,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function mondays()
|
||||
{
|
||||
return $this->days(1);
|
||||
return $this->days(Schedule::MONDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -306,7 +319,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function tuesdays()
|
||||
{
|
||||
return $this->days(2);
|
||||
return $this->days(Schedule::TUESDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -316,7 +329,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function wednesdays()
|
||||
{
|
||||
return $this->days(3);
|
||||
return $this->days(Schedule::WEDNESDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -326,7 +339,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function thursdays()
|
||||
{
|
||||
return $this->days(4);
|
||||
return $this->days(Schedule::THURSDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -336,7 +349,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function fridays()
|
||||
{
|
||||
return $this->days(5);
|
||||
return $this->days(Schedule::FRIDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,7 +359,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function saturdays()
|
||||
{
|
||||
return $this->days(6);
|
||||
return $this->days(Schedule::SATURDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,7 +369,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function sundays()
|
||||
{
|
||||
return $this->days(0);
|
||||
return $this->days(Schedule::SUNDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -374,15 +387,15 @@ trait ManagesFrequencies
|
||||
/**
|
||||
* Schedule the event to run weekly on a given day and time.
|
||||
*
|
||||
* @param int $day
|
||||
* @param array|mixed $dayOfWeek
|
||||
* @param string $time
|
||||
* @return $this
|
||||
*/
|
||||
public function weeklyOn($day, $time = '0:0')
|
||||
public function weeklyOn($dayOfWeek, $time = '0:0')
|
||||
{
|
||||
$this->dailyAt($time);
|
||||
|
||||
return $this->spliceIntoPosition(5, $day);
|
||||
return $this->days($dayOfWeek);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,15 +413,15 @@ trait ManagesFrequencies
|
||||
/**
|
||||
* Schedule the event to run monthly on a given day and time.
|
||||
*
|
||||
* @param int $day
|
||||
* @param int $dayOfMonth
|
||||
* @param string $time
|
||||
* @return $this
|
||||
*/
|
||||
public function monthlyOn($day = 1, $time = '0:0')
|
||||
public function monthlyOn($dayOfMonth = 1, $time = '0:0')
|
||||
{
|
||||
$this->dailyAt($time);
|
||||
|
||||
return $this->spliceIntoPosition(3, $day);
|
||||
return $this->spliceIntoPosition(3, $dayOfMonth);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -421,13 +434,11 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function twiceMonthly($first = 1, $second = 16, $time = '0:0')
|
||||
{
|
||||
$days = $first.','.$second;
|
||||
$daysOfMonth = $first.','.$second;
|
||||
|
||||
$this->dailyAt($time);
|
||||
|
||||
return $this->spliceIntoPosition(1, 0)
|
||||
->spliceIntoPosition(2, 0)
|
||||
->spliceIntoPosition(3, $days);
|
||||
return $this->spliceIntoPosition(3, $daysOfMonth);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -469,6 +480,22 @@ trait ManagesFrequencies
|
||||
->spliceIntoPosition(4, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule the event to run yearly on a given month, day, and time.
|
||||
*
|
||||
* @param int $month
|
||||
* @param int|string $dayOfMonth
|
||||
* @param string $time
|
||||
* @return $this
|
||||
*/
|
||||
public function yearlyOn($month = 1, $dayOfMonth = 1, $time = '0:0')
|
||||
{
|
||||
$this->dailyAt($time);
|
||||
|
||||
return $this->spliceIntoPosition(3, $dayOfMonth)
|
||||
->spliceIntoPosition(4, $month);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the days of the week the command should run on.
|
||||
*
|
||||
|
||||
@@ -4,10 +4,13 @@ namespace Illuminate\Console\Scheduling;
|
||||
|
||||
use Closure;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Bus\UniqueLock;
|
||||
use Illuminate\Console\Application;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Contracts\Bus\Dispatcher;
|
||||
use Illuminate\Contracts\Cache\Repository as Cache;
|
||||
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\CallQueuedClosure;
|
||||
use Illuminate\Support\ProcessUtils;
|
||||
@@ -19,6 +22,14 @@ class Schedule
|
||||
{
|
||||
use Macroable;
|
||||
|
||||
const SUNDAY = 0;
|
||||
const MONDAY = 1;
|
||||
const TUESDAY = 2;
|
||||
const WEDNESDAY = 3;
|
||||
const THURSDAY = 4;
|
||||
const FRIDAY = 5;
|
||||
const SATURDAY = 6;
|
||||
|
||||
/**
|
||||
* All of the events on the schedule.
|
||||
*
|
||||
@@ -59,6 +70,8 @@ class Schedule
|
||||
*
|
||||
* @param \DateTimeZone|string|null $timezone
|
||||
* @return void
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function __construct($timezone = null)
|
||||
{
|
||||
@@ -107,7 +120,11 @@ class Schedule
|
||||
public function command($command, array $parameters = [])
|
||||
{
|
||||
if (class_exists($command)) {
|
||||
$command = Container::getInstance()->make($command)->getName();
|
||||
$command = Container::getInstance()->make($command);
|
||||
|
||||
return $this->exec(
|
||||
Application::formatCommandString($command->getName()), $parameters,
|
||||
)->description($command->getDescription());
|
||||
}
|
||||
|
||||
return $this->exec(
|
||||
@@ -143,6 +160,8 @@ class Schedule
|
||||
* @param string|null $queue
|
||||
* @param string|null $connection
|
||||
* @return void
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function dispatchToQueue($job, $queue, $connection)
|
||||
{
|
||||
@@ -156,6 +175,35 @@ class Schedule
|
||||
$job = CallQueuedClosure::create($job);
|
||||
}
|
||||
|
||||
if ($job instanceof ShouldBeUnique) {
|
||||
return $this->dispatchUniqueJobToQueue($job, $queue, $connection);
|
||||
}
|
||||
|
||||
$this->getDispatcher()->dispatch(
|
||||
$job->onConnection($connection)->onQueue($queue)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch the given unique job to the queue.
|
||||
*
|
||||
* @param object $job
|
||||
* @param string|null $queue
|
||||
* @param string|null $connection
|
||||
* @return void
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function dispatchUniqueJobToQueue($job, $queue, $connection)
|
||||
{
|
||||
if (! Container::getInstance()->bound(Cache::class)) {
|
||||
throw new RuntimeException('Cache driver not available. Scheduling unique jobs not supported.');
|
||||
}
|
||||
|
||||
if (! (new UniqueLock(Container::getInstance()->make(Cache::class)))->acquire($job)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->getDispatcher()->dispatch(
|
||||
$job->onConnection($connection)->onQueue($queue)
|
||||
);
|
||||
@@ -293,6 +341,8 @@ class Schedule
|
||||
* Get the job dispatcher, if available.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Bus\Dispatcher
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function getDispatcher()
|
||||
{
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace Illuminate\Console\Scheduling;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Console\Events\ScheduledBackgroundTaskFinished;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class ScheduleFinishCommand extends Command
|
||||
{
|
||||
@@ -37,6 +39,10 @@ class ScheduleFinishCommand extends Command
|
||||
{
|
||||
collect($schedule->events())->filter(function ($value) {
|
||||
return $value->mutexName() == $this->argument('id');
|
||||
})->each->callAfterCallbacksWithExitCode($this->laravel, $this->argument('code'));
|
||||
})->each(function ($event) {
|
||||
$event->callafterCallbacksWithExitCode($this->laravel, $this->argument('code'));
|
||||
|
||||
$this->laravel->make(Dispatcher::class)->dispatch(new ScheduledBackgroundTaskFinished($event));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ class ScheduleRunCommand extends Command
|
||||
*/
|
||||
protected function runEvent($event)
|
||||
{
|
||||
$this->line('<info>Running scheduled command:</info> '.$event->getSummaryForDisplay());
|
||||
$this->line('<info>['.date('c').'] Running scheduled command:</info> '.$event->getSummaryForDisplay());
|
||||
|
||||
$this->dispatcher->dispatch(new ScheduledTaskStarting($event));
|
||||
|
||||
|
||||
26
vendor/laravel/framework/src/Illuminate/Console/composer.json
vendored
Normal file → Executable file
26
vendor/laravel/framework/src/Illuminate/Console/composer.json
vendored
Normal file → Executable file
@@ -14,11 +14,13 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2.5|^8.0",
|
||||
"illuminate/contracts": "^7.0",
|
||||
"illuminate/support": "^7.0",
|
||||
"symfony/console": "^5.0",
|
||||
"symfony/process": "^5.0"
|
||||
"php": "^7.3|^8.0",
|
||||
"illuminate/collections": "^8.0",
|
||||
"illuminate/contracts": "^8.0",
|
||||
"illuminate/macroable": "^8.0",
|
||||
"illuminate/support": "^8.0",
|
||||
"symfony/console": "^5.4",
|
||||
"symfony/process": "^5.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -27,16 +29,16 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "7.x-dev"
|
||||
"dev-master": "8.x-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"dragonmantank/cron-expression": "Required to use scheduler (^2.3.1).",
|
||||
"guzzlehttp/guzzle": "Required to use the ping methods on schedules (^6.3.1|^7.0.1).",
|
||||
"illuminate/bus": "Required to use the scheduled job dispatcher (^7.0).",
|
||||
"illuminate/container": "Required to use the scheduler (^7.0).",
|
||||
"illuminate/filesystem": "Required to use the generator command (^7.0).",
|
||||
"illuminate/queue": "Required to use closures for scheduled jobs (^7.0)."
|
||||
"dragonmantank/cron-expression": "Required to use scheduler (^3.0.2).",
|
||||
"guzzlehttp/guzzle": "Required to use the ping methods on schedules (^6.5.5|^7.0.1).",
|
||||
"illuminate/bus": "Required to use the scheduled job dispatcher (^8.0).",
|
||||
"illuminate/container": "Required to use the scheduler (^8.0).",
|
||||
"illuminate/filesystem": "Required to use the generator command (^8.0).",
|
||||
"illuminate/queue": "Required to use closures for scheduled jobs (^8.0)."
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
|
||||
@@ -156,6 +156,8 @@ class BoundMethod
|
||||
* @param array $parameters
|
||||
* @param array $dependencies
|
||||
* @return void
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
protected static function addDependencyForCallParameter($container, $parameter,
|
||||
array &$parameters, &$dependencies)
|
||||
@@ -170,7 +172,15 @@ class BoundMethod
|
||||
|
||||
unset($parameters[$className]);
|
||||
} else {
|
||||
$dependencies[] = $container->make($className);
|
||||
if ($parameter->isVariadic()) {
|
||||
$variadicDependencies = $container->make($className);
|
||||
|
||||
$dependencies = array_merge($dependencies, is_array($variadicDependencies)
|
||||
? $variadicDependencies
|
||||
: [$variadicDependencies]);
|
||||
} else {
|
||||
$dependencies[] = $container->make($className);
|
||||
}
|
||||
}
|
||||
} elseif ($parameter->isDefaultValueAvailable()) {
|
||||
$dependencies[] = $parameter->getDefaultValue();
|
||||
|
||||
174
vendor/laravel/framework/src/Illuminate/Container/Container.php
vendored
Normal file → Executable file
174
vendor/laravel/framework/src/Illuminate/Container/Container.php
vendored
Normal file → Executable file
@@ -6,11 +6,13 @@ use ArrayAccess;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||
use Illuminate\Contracts\Container\CircularDependencyException;
|
||||
use Illuminate\Contracts\Container\Container as ContainerContract;
|
||||
use LogicException;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
use ReflectionParameter;
|
||||
use TypeError;
|
||||
|
||||
class Container implements ArrayAccess, ContainerContract
|
||||
{
|
||||
@@ -49,6 +51,13 @@ class Container implements ArrayAccess, ContainerContract
|
||||
*/
|
||||
protected $instances = [];
|
||||
|
||||
/**
|
||||
* The container's scoped instances.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $scopedInstances = [];
|
||||
|
||||
/**
|
||||
* The registered type aliases.
|
||||
*
|
||||
@@ -105,6 +114,13 @@ class Container implements ArrayAccess, ContainerContract
|
||||
*/
|
||||
protected $reboundCallbacks = [];
|
||||
|
||||
/**
|
||||
* All of the global before resolving callbacks.
|
||||
*
|
||||
* @var \Closure[]
|
||||
*/
|
||||
protected $globalBeforeResolvingCallbacks = [];
|
||||
|
||||
/**
|
||||
* All of the global resolving callbacks.
|
||||
*
|
||||
@@ -119,6 +135,13 @@ class Container implements ArrayAccess, ContainerContract
|
||||
*/
|
||||
protected $globalAfterResolvingCallbacks = [];
|
||||
|
||||
/**
|
||||
* All of the before resolving callbacks by class type.
|
||||
*
|
||||
* @var array[]
|
||||
*/
|
||||
protected $beforeResolvingCallbacks = [];
|
||||
|
||||
/**
|
||||
* All of the resolving callbacks by class type.
|
||||
*
|
||||
@@ -164,7 +187,9 @@ class Container implements ArrayAccess, ContainerContract
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has($id)
|
||||
{
|
||||
@@ -218,6 +243,8 @@ class Container implements ArrayAccess, ContainerContract
|
||||
* @param \Closure|string|null $concrete
|
||||
* @param bool $shared
|
||||
* @return void
|
||||
*
|
||||
* @throws \TypeError
|
||||
*/
|
||||
public function bind($abstract, $concrete = null, $shared = false)
|
||||
{
|
||||
@@ -235,7 +262,7 @@ class Container implements ArrayAccess, ContainerContract
|
||||
// up inside its own Closure to give us more convenience when extending.
|
||||
if (! $concrete instanceof Closure) {
|
||||
if (! is_string($concrete)) {
|
||||
throw new \TypeError(self::class.'::bind(): Argument #2 ($concrete) must be of type Closure|string|null');
|
||||
throw new TypeError(self::class.'::bind(): Argument #2 ($concrete) must be of type Closure|string|null');
|
||||
}
|
||||
|
||||
$concrete = $this->getClosure($abstract, $concrete);
|
||||
@@ -375,6 +402,36 @@ class Container implements ArrayAccess, ContainerContract
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a scoped binding in the container.
|
||||
*
|
||||
* @param string $abstract
|
||||
* @param \Closure|string|null $concrete
|
||||
* @return void
|
||||
*/
|
||||
public function scoped($abstract, $concrete = null)
|
||||
{
|
||||
$this->scopedInstances[] = $abstract;
|
||||
|
||||
$this->singleton($abstract, $concrete);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a scoped binding if it hasn't already been registered.
|
||||
*
|
||||
* @param string $abstract
|
||||
* @param \Closure|string|null $concrete
|
||||
* @return void
|
||||
*/
|
||||
public function scopedIf($abstract, $concrete = null)
|
||||
{
|
||||
if (! $this->bound($abstract)) {
|
||||
$this->scopedInstances[] = $abstract;
|
||||
|
||||
$this->singleton($abstract, $concrete);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* "Extend" an abstract type in the container.
|
||||
*
|
||||
@@ -612,7 +669,7 @@ class Container implements ArrayAccess, ContainerContract
|
||||
/**
|
||||
* An alias function name for make().
|
||||
*
|
||||
* @param string $abstract
|
||||
* @param string|callable $abstract
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*
|
||||
@@ -626,7 +683,7 @@ class Container implements ArrayAccess, ContainerContract
|
||||
/**
|
||||
* Resolve the given type from the container.
|
||||
*
|
||||
* @param string $abstract
|
||||
* @param string|callable $abstract
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*
|
||||
@@ -638,14 +695,16 @@ class Container implements ArrayAccess, ContainerContract
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($id)
|
||||
{
|
||||
try {
|
||||
return $this->resolve($id);
|
||||
} catch (Exception $e) {
|
||||
if ($this->has($id)) {
|
||||
if ($this->has($id) || $e instanceof CircularDependencyException) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
@@ -656,17 +715,25 @@ class Container implements ArrayAccess, ContainerContract
|
||||
/**
|
||||
* Resolve the given type from the container.
|
||||
*
|
||||
* @param string $abstract
|
||||
* @param string|callable $abstract
|
||||
* @param array $parameters
|
||||
* @param bool $raiseEvents
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
* @throws \Illuminate\Contracts\Container\CircularDependencyException
|
||||
*/
|
||||
protected function resolve($abstract, $parameters = [], $raiseEvents = true)
|
||||
{
|
||||
$abstract = $this->getAlias($abstract);
|
||||
|
||||
// First we'll fire any event handlers which handle the "before" resolving of
|
||||
// specific types. This gives some hooks the chance to add various extends
|
||||
// calls to change the resolution of objects that they're interested in.
|
||||
if ($raiseEvents) {
|
||||
$this->fireBeforeResolvingCallbacks($abstract, $parameters);
|
||||
}
|
||||
|
||||
$concrete = $this->getContextualConcrete($abstract);
|
||||
|
||||
$needsContextualBuild = ! empty($parameters) || ! is_null($concrete);
|
||||
@@ -724,7 +791,7 @@ class Container implements ArrayAccess, ContainerContract
|
||||
/**
|
||||
* Get the concrete type for a given abstract.
|
||||
*
|
||||
* @param string $abstract
|
||||
* @param string|callable $abstract
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getConcrete($abstract)
|
||||
@@ -742,7 +809,7 @@ class Container implements ArrayAccess, ContainerContract
|
||||
/**
|
||||
* Get the contextual concrete binding for the given abstract.
|
||||
*
|
||||
* @param string $abstract
|
||||
* @param string|callable $abstract
|
||||
* @return \Closure|string|array|null
|
||||
*/
|
||||
protected function getContextualConcrete($abstract)
|
||||
@@ -768,7 +835,7 @@ class Container implements ArrayAccess, ContainerContract
|
||||
/**
|
||||
* Find the concrete binding for the given abstract in the contextual binding array.
|
||||
*
|
||||
* @param string $abstract
|
||||
* @param string|callable $abstract
|
||||
* @return \Closure|string|null
|
||||
*/
|
||||
protected function findInContextualBindings($abstract)
|
||||
@@ -795,6 +862,7 @@ class Container implements ArrayAccess, ContainerContract
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
* @throws \Illuminate\Contracts\Container\CircularDependencyException
|
||||
*/
|
||||
public function build($concrete)
|
||||
{
|
||||
@@ -964,10 +1032,14 @@ class Container implements ArrayAccess, ContainerContract
|
||||
// the value of the dependency, similarly to how we do this with scalars.
|
||||
catch (BindingResolutionException $e) {
|
||||
if ($parameter->isDefaultValueAvailable()) {
|
||||
array_pop($this->with);
|
||||
|
||||
return $parameter->getDefaultValue();
|
||||
}
|
||||
|
||||
if ($parameter->isVariadic()) {
|
||||
array_pop($this->with);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -1032,6 +1104,26 @@ class Container implements ArrayAccess, ContainerContract
|
||||
throw new BindingResolutionException($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new before resolving callback for all types.
|
||||
*
|
||||
* @param \Closure|string $abstract
|
||||
* @param \Closure|null $callback
|
||||
* @return void
|
||||
*/
|
||||
public function beforeResolving($abstract, Closure $callback = null)
|
||||
{
|
||||
if (is_string($abstract)) {
|
||||
$abstract = $this->getAlias($abstract);
|
||||
}
|
||||
|
||||
if ($abstract instanceof Closure && is_null($callback)) {
|
||||
$this->globalBeforeResolvingCallbacks[] = $abstract;
|
||||
} else {
|
||||
$this->beforeResolvingCallbacks[$abstract][] = $callback;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new resolving callback.
|
||||
*
|
||||
@@ -1072,6 +1164,39 @@ class Container implements ArrayAccess, ContainerContract
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire all of the before resolving callbacks.
|
||||
*
|
||||
* @param string $abstract
|
||||
* @param array $parameters
|
||||
* @return void
|
||||
*/
|
||||
protected function fireBeforeResolvingCallbacks($abstract, $parameters = [])
|
||||
{
|
||||
$this->fireBeforeCallbackArray($abstract, $parameters, $this->globalBeforeResolvingCallbacks);
|
||||
|
||||
foreach ($this->beforeResolvingCallbacks as $type => $callbacks) {
|
||||
if ($type === $abstract || is_subclass_of($abstract, $type)) {
|
||||
$this->fireBeforeCallbackArray($abstract, $parameters, $callbacks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire an array of callbacks with an object.
|
||||
*
|
||||
* @param string $abstract
|
||||
* @param array $parameters
|
||||
* @param array $callbacks
|
||||
* @return void
|
||||
*/
|
||||
protected function fireBeforeCallbackArray($abstract, $parameters, array $callbacks)
|
||||
{
|
||||
foreach ($callbacks as $callback) {
|
||||
$callback($abstract, $parameters, $this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire all of the resolving callbacks.
|
||||
*
|
||||
@@ -1159,11 +1284,9 @@ class Container implements ArrayAccess, ContainerContract
|
||||
*/
|
||||
public function getAlias($abstract)
|
||||
{
|
||||
if (! isset($this->aliases[$abstract])) {
|
||||
return $abstract;
|
||||
}
|
||||
|
||||
return $this->getAlias($this->aliases[$abstract]);
|
||||
return isset($this->aliases[$abstract])
|
||||
? $this->getAlias($this->aliases[$abstract])
|
||||
: $abstract;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1174,9 +1297,7 @@ class Container implements ArrayAccess, ContainerContract
|
||||
*/
|
||||
protected function getExtenders($abstract)
|
||||
{
|
||||
$abstract = $this->getAlias($abstract);
|
||||
|
||||
return $this->extenders[$abstract] ?? [];
|
||||
return $this->extenders[$this->getAlias($abstract)] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1222,6 +1343,18 @@ class Container implements ArrayAccess, ContainerContract
|
||||
$this->instances = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all of the scoped instances from the container.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function forgetScopedInstances()
|
||||
{
|
||||
foreach ($this->scopedInstances as $scoped) {
|
||||
unset($this->instances[$scoped]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the container of all bindings and resolved instances.
|
||||
*
|
||||
@@ -1234,6 +1367,7 @@ class Container implements ArrayAccess, ContainerContract
|
||||
$this->bindings = [];
|
||||
$this->instances = [];
|
||||
$this->abstractAliases = [];
|
||||
$this->scopedInstances = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1267,6 +1401,7 @@ class Container implements ArrayAccess, ContainerContract
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($key)
|
||||
{
|
||||
return $this->bound($key);
|
||||
@@ -1278,6 +1413,7 @@ class Container implements ArrayAccess, ContainerContract
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($key)
|
||||
{
|
||||
return $this->make($key);
|
||||
@@ -1290,6 +1426,7 @@ class Container implements ArrayAccess, ContainerContract
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($key, $value)
|
||||
{
|
||||
$this->bind($key, $value instanceof Closure ? $value : function () use ($value) {
|
||||
@@ -1303,6 +1440,7 @@ class Container implements ArrayAccess, ContainerContract
|
||||
* @param string $key
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($key)
|
||||
{
|
||||
unset($this->bindings[$key], $this->instances[$key], $this->resolved[$key]);
|
||||
|
||||
@@ -81,4 +81,18 @@ class ContextualBindingBuilder implements ContextualBindingBuilderContract
|
||||
return is_array($taggedServices) ? $taggedServices : iterator_to_array($taggedServices);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the configuration item to bind as a primitive.
|
||||
*
|
||||
* @param string $key
|
||||
* @param ?string $default
|
||||
* @return void
|
||||
*/
|
||||
public function giveConfig($key, $default = null)
|
||||
{
|
||||
$this->give(function ($container) use ($key, $default) {
|
||||
return $container->get('config')->get($key, $default);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ class RewindableGenerator implements Countable, IteratorAggregate
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
{
|
||||
return ($this->generator)();
|
||||
@@ -49,6 +50,7 @@ class RewindableGenerator implements Countable, IteratorAggregate
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count()
|
||||
{
|
||||
if (is_callable($count = $this->count)) {
|
||||
|
||||
@@ -5,6 +5,9 @@ namespace Illuminate\Container;
|
||||
use Closure;
|
||||
use ReflectionNamedType;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class Util
|
||||
{
|
||||
/**
|
||||
@@ -50,7 +53,7 @@ class Util
|
||||
$type = $parameter->getType();
|
||||
|
||||
if (! $type instanceof ReflectionNamedType || $type->isBuiltin()) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$name = $type->getName();
|
||||
|
||||
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
@@ -14,8 +14,8 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2.5|^8.0",
|
||||
"illuminate/contracts": "^7.0",
|
||||
"php": "^7.3|^8.0",
|
||||
"illuminate/contracts": "^8.0",
|
||||
"psr/container": "^1.0"
|
||||
},
|
||||
"provide": {
|
||||
@@ -28,7 +28,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "7.x-dev"
|
||||
"dev-master": "8.x-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
||||
@@ -45,9 +45,10 @@ interface PasswordBroker
|
||||
* Send a password reset link to a user.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param \Closure|null $callback
|
||||
* @return string
|
||||
*/
|
||||
public function sendResetLink(array $credentials);
|
||||
public function sendResetLink(array $credentials, Closure $callback = null);
|
||||
|
||||
/**
|
||||
* Reset the password for the given token.
|
||||
|
||||
@@ -35,7 +35,7 @@ interface StatefulGuard extends Guard
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param bool $remember
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|bool
|
||||
*/
|
||||
public function loginUsingId($id, $remember = false);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ interface ShouldBroadcast
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[]
|
||||
* @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[]|string[]|string
|
||||
*/
|
||||
public function broadcastOn();
|
||||
}
|
||||
|
||||
@@ -12,6 +12,17 @@ interface Dispatcher
|
||||
*/
|
||||
public function dispatch($command);
|
||||
|
||||
/**
|
||||
* Dispatch a command to its appropriate handler in the current process.
|
||||
*
|
||||
* Queueable jobs will be dispatched to the "sync" queue.
|
||||
*
|
||||
* @param mixed $command
|
||||
* @param mixed $handler
|
||||
* @return mixed
|
||||
*/
|
||||
public function dispatchSync($command, $handler = null);
|
||||
|
||||
/**
|
||||
* Dispatch a command to its appropriate handler in the current process.
|
||||
*
|
||||
|
||||
@@ -4,6 +4,22 @@ namespace Illuminate\Contracts\Bus;
|
||||
|
||||
interface QueueingDispatcher extends Dispatcher
|
||||
{
|
||||
/**
|
||||
* Attempt to find the batch with the given ID.
|
||||
*
|
||||
* @param string $batchId
|
||||
* @return \Illuminate\Bus\Batch|null
|
||||
*/
|
||||
public function findBatch(string $batchId);
|
||||
|
||||
/**
|
||||
* Create a new batch of queueable jobs.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection|array $jobs
|
||||
* @return \Illuminate\Bus\PendingBatch
|
||||
*/
|
||||
public function batch($jobs);
|
||||
|
||||
/**
|
||||
* Dispatch a command to its appropriate handler behind a queue.
|
||||
*
|
||||
|
||||
@@ -17,7 +17,7 @@ interface Lock
|
||||
*
|
||||
* @param int $seconds
|
||||
* @param callable|null $callback
|
||||
* @return bool
|
||||
* @return mixed
|
||||
*/
|
||||
public function block($seconds, $callback = null);
|
||||
|
||||
|
||||
@@ -4,6 +4,13 @@ namespace Illuminate\Contracts\Console;
|
||||
|
||||
interface Kernel
|
||||
{
|
||||
/**
|
||||
* Bootstrap the application for artisan commands.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function bootstrap();
|
||||
|
||||
/**
|
||||
* Handle an incoming console command.
|
||||
*
|
||||
|
||||
@@ -15,8 +15,16 @@ interface ContextualBindingBuilder
|
||||
/**
|
||||
* Define the implementation for the contextual binding.
|
||||
*
|
||||
* @param \Closure|string $implementation
|
||||
* @param \Closure|string|array $implementation
|
||||
* @return void
|
||||
*/
|
||||
public function give($implementation);
|
||||
|
||||
/**
|
||||
* Define tagged services to be used as the implementation for the contextual binding.
|
||||
*
|
||||
* @param string $tag
|
||||
* @return void
|
||||
*/
|
||||
public function giveTagged($tag);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ interface Castable
|
||||
/**
|
||||
* Get the name of the caster class to use when casting from / to this cast target.
|
||||
*
|
||||
* @param array $arguments
|
||||
* @return string
|
||||
* @return string|\Illuminate\Contracts\Database\Eloquent\CastsAttributes|\Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes
|
||||
*/
|
||||
public static function castUsing();
|
||||
public static function castUsing(array $arguments);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ interface Dispatcher
|
||||
/**
|
||||
* Register an event listener with the dispatcher.
|
||||
*
|
||||
* @param string|array $events
|
||||
* @param \Closure|string $listener
|
||||
* @param \Closure|string|array $events
|
||||
* @param \Closure|string|array|null $listener
|
||||
* @return void
|
||||
*/
|
||||
public function listen($events, $listener);
|
||||
public function listen($events, $listener = null);
|
||||
|
||||
/**
|
||||
* Determine if a given event has listeners.
|
||||
|
||||
@@ -24,7 +24,7 @@ interface Application extends Container
|
||||
/**
|
||||
* Get the path to the bootstrap directory.
|
||||
*
|
||||
* @param string $path Optionally, a path to append to the bootstrap path
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function bootstrapPath($path = '');
|
||||
@@ -32,7 +32,7 @@ interface Application extends Container
|
||||
/**
|
||||
* Get the path to the application configuration files.
|
||||
*
|
||||
* @param string $path Optionally, a path to append to the config path
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function configPath($path = '');
|
||||
@@ -40,7 +40,7 @@ interface Application extends Container
|
||||
/**
|
||||
* Get the path to the database directory.
|
||||
*
|
||||
* @param string $path Optionally, a path to append to the database path
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function databasePath($path = '');
|
||||
|
||||
@@ -8,7 +8,7 @@ interface Factory
|
||||
* Get a mailer instance by name.
|
||||
*
|
||||
* @param string|null $name
|
||||
* @return \Illuminate\Mail\Mailer
|
||||
* @return \Illuminate\Contracts\Mail\Mailer
|
||||
*/
|
||||
public function mailer($name = null);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ interface Job
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function timeoutAt();
|
||||
public function retryUntil();
|
||||
|
||||
/**
|
||||
* Get the name of the queued job class.
|
||||
|
||||
@@ -7,7 +7,7 @@ interface ResponseFactory
|
||||
/**
|
||||
* Create a new response instance.
|
||||
*
|
||||
* @param string $content
|
||||
* @param array|string $content
|
||||
* @param int $status
|
||||
* @param array $headers
|
||||
* @return \Illuminate\Http\Response
|
||||
|
||||
@@ -11,6 +11,14 @@ interface Session
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* Set the name of the session.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function setName($name);
|
||||
|
||||
/**
|
||||
* Get the current session ID.
|
||||
*
|
||||
@@ -72,6 +80,15 @@ interface Session
|
||||
*/
|
||||
public function get($key, $default = null);
|
||||
|
||||
/**
|
||||
* Get the value of a given key and then forget it.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function pull($key, $default = null);
|
||||
|
||||
/**
|
||||
* Put a key / value pair or array of key / value pairs in the session.
|
||||
*
|
||||
@@ -88,6 +105,13 @@ interface Session
|
||||
*/
|
||||
public function token();
|
||||
|
||||
/**
|
||||
* Regenerate the CSRF token value.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function regenerateToken();
|
||||
|
||||
/**
|
||||
* Remove an item from the session, returning its value.
|
||||
*
|
||||
@@ -111,6 +135,21 @@ interface Session
|
||||
*/
|
||||
public function flush();
|
||||
|
||||
/**
|
||||
* Flush the session data and regenerate the ID.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function invalidate();
|
||||
|
||||
/**
|
||||
* Generate a new session identifier.
|
||||
*
|
||||
* @param bool $destroy
|
||||
* @return bool
|
||||
*/
|
||||
public function regenerate($destroy = false);
|
||||
|
||||
/**
|
||||
* Generate a new session ID for the session.
|
||||
*
|
||||
|
||||
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
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
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user