generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the namespace and add interactive facade (#5)
* Add RBAC package registration and service binding * Refactor rbacContainsDuplicateAbilities method signature * Add test for throwing duplicate permission exception * Update composer.json with Laravel 11 enum-backed RBAC * Update namespace from BinaryCats\Rbac to BinaryCats\LaravelRbac * Enhance Laravel 11 with opinionated extension * Apply fixes from StyleCI --------- Co-authored-by: StyleCI Bot <bot@styleci.io>
- Loading branch information
1 parent
692631d
commit c119629
Showing
37 changed files
with
277 additions
and
101 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
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,6 +1,6 @@ | ||
<?php | ||
|
||
namespace BinaryCats\Rbac\Contracts; | ||
namespace BinaryCats\LaravelRbac\Contracts; | ||
|
||
interface DefinedRole | ||
{ | ||
|
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace BinaryCats\LaravelRbac\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
class Rbac extends Facade | ||
{ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return \BinaryCats\LaravelRbac\Rbac::class; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace BinaryCats\LaravelRbac; | ||
|
||
use Illuminate\Support\Collection; | ||
|
||
class Rbac | ||
{ | ||
/** @var string */ | ||
protected string $abilitiesPath; | ||
|
||
/** @var string */ | ||
protected string $basePath; | ||
|
||
/** @var \Illuminate\Support\Collection|null */ | ||
protected ?Collection $abilities = null; | ||
|
||
/** | ||
* @param string $abilitiesPath | ||
* @param string $basePath | ||
*/ | ||
public function __construct(string $abilitiesPath, string $basePath) | ||
{ | ||
$this->abilitiesPath = $abilitiesPath; | ||
$this->basePath = $basePath; | ||
} | ||
|
||
/** | ||
* Return the list of all abilities in the application. | ||
*/ | ||
public function abilities(): Collection | ||
{ | ||
if (null === $this->abilities) { | ||
$this->abilities = $this->discoverAbilities(); | ||
} | ||
|
||
return $this->abilities; | ||
} | ||
|
||
/** | ||
* Discover Abilities in path. | ||
*/ | ||
protected function discoverAbilities(): Collection | ||
{ | ||
return DiscoverAbilities::within( | ||
abilitiesPath: $this->abilitiesPath, | ||
basePath: $this->basePath | ||
); | ||
} | ||
} |
Oops, something went wrong.