-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from ARCANEDEV/update-package
Updating the package
- Loading branch information
Showing
13 changed files
with
108 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,67 @@ | ||
<?php namespace Arcanedev\LaravelImpersonator\Exceptions; | ||
|
||
use Arcanedev\LaravelImpersonator\Contracts\Impersonatable; | ||
|
||
/** | ||
* Class ImpersonationException | ||
* | ||
* @package Arcanedev\LaravelImpersonator\Exceptions | ||
* @author ARCANEDEV <[email protected]> | ||
*/ | ||
class ImpersonationException extends \Exception {} | ||
class ImpersonationException extends \Exception | ||
{ | ||
/* ----------------------------------------------------------------- | ||
| Main Methods | ||
| ----------------------------------------------------------------- | ||
*/ | ||
|
||
/** | ||
* Make a new exception. | ||
* | ||
* @param string $message | ||
* | ||
* @return static | ||
*/ | ||
public static function make(string $message): self | ||
{ | ||
return new static($message); | ||
} | ||
|
||
/** | ||
* Make an exception when the impersonater and impersonated are same person. | ||
* | ||
* @return static | ||
*/ | ||
public static function selfImpersonation(): self | ||
{ | ||
return static::make('The impersonater & impersonated with must be different.'); | ||
} | ||
|
||
/** | ||
* Make an exception when the impersonater cannot (or not allowed) impersonate. | ||
* | ||
* @param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable $impersonater | ||
* | ||
* @return static | ||
*/ | ||
public static function cannotImpersonate(Impersonatable $impersonater): self | ||
{ | ||
return static::make( | ||
"The impersonater with `{$impersonater->getAuthIdentifierName()}`=[{$impersonater->getAuthIdentifier()}] doesn't have the ability to impersonate." | ||
); | ||
} | ||
|
||
/** | ||
* Make an exception when the impersonated cannot be impersonated. | ||
* | ||
* @param \Arcanedev\LaravelImpersonator\Contracts\Impersonatable $impersonated | ||
* | ||
* @return static | ||
*/ | ||
public static function cannotBeImpersonated(Impersonatable $impersonated) | ||
{ | ||
return static::make( | ||
"The impersonated with `{$impersonated->getAuthIdentifierName()}`=[{$impersonated->getAuthIdentifier()}] cannot be impersonated." | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
<?php namespace Arcanedev\LaravelImpersonator; | ||
|
||
use Arcanedev\Support\PackageServiceProvider; | ||
use Arcanedev\Support\Providers\PackageServiceProvider; | ||
use Illuminate\Auth\SessionGuard as IlluminateSessionGuard; | ||
use Illuminate\Contracts\Foundation\Application; | ||
use Illuminate\Contracts\Support\DeferrableProvider; | ||
|
||
/** | ||
* Class ImpersonatorServiceProvider | ||
* | ||
* @package Arcanedev\LaravelImpersonator | ||
* @author ARCANEDEV <[email protected]> | ||
*/ | ||
class ImpersonatorServiceProvider extends PackageServiceProvider | ||
class ImpersonatorServiceProvider extends PackageServiceProvider implements DeferrableProvider | ||
{ | ||
/* ----------------------------------------------------------------- | ||
| Properties | ||
|
@@ -32,7 +33,7 @@ class ImpersonatorServiceProvider extends PackageServiceProvider | |
/** | ||
* Register the service provider. | ||
*/ | ||
public function register() | ||
public function register(): void | ||
{ | ||
parent::register(); | ||
|
||
|
@@ -47,10 +48,8 @@ public function register() | |
/** | ||
* Boot the service provider. | ||
*/ | ||
public function boot() | ||
public function boot(): void | ||
{ | ||
parent::boot(); | ||
|
||
$this->publishConfig(); | ||
} | ||
|
||
|
@@ -59,7 +58,7 @@ public function boot() | |
* | ||
* @return array | ||
*/ | ||
public function provides() | ||
public function provides(): array | ||
{ | ||
return [ | ||
Contracts\Impersonator::class, | ||
|
@@ -74,7 +73,7 @@ public function provides() | |
/** | ||
* Extend the auth session driver. | ||
*/ | ||
private function extendAuthDriver() | ||
private function extendAuthDriver(): void | ||
{ | ||
/** @var \Illuminate\Auth\AuthManager $auth */ | ||
$auth = $this->app['auth']; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters