Skip to content

Commit

Permalink
Use setter to assign Guard allowing this to be use on non-laravel app.
Browse files Browse the repository at this point in the history
Signed-off-by: crynobone <crynobone@gmail.com>
  • Loading branch information
crynobone committed Sep 19, 2015
1 parent 8dec157 commit 4d23be2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions src/Authorization/Authorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,34 @@ class Authorization implements AuthorizationContract
/**
* Construct a new object.
*
* @param \Orchestra\Contracts\Auth\Guard $auth
* @param string $name
* @param \Orchestra\Contracts\Memory\Provider|null $memory
*/
public function __construct(Guard $auth, $name, Provider $memory = null)
public function __construct($name, Provider $memory = null)
{
$this->auth = $auth;
$this->name = $name;
$this->name = $name;

$this->roles = new Fluent('roles');
$this->actions = new Fluent('actions');

$this->roles->add('guest');
$this->attach($memory);
}

/**
* Set authenticator.
*
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return $this
*/
public function setAuthenticator(Guard $auth)
{
$this->auth = $auth;

return $this;
}

/**
* Bind current ACL instance with a Memory instance.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Authorization/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function make($name = null, Provider $memory = null)
$name = ! is_null($name) ? $name : 'default';

if (! isset($this->drivers[$name])) {
$this->drivers[$name] = new Authorization($this->auth, $name, $memory);
$this->drivers[$name] = (new Authorization($name, $memory))->setAuthenticator($this->auth);
}

return $this->drivers[$name];
Expand Down

0 comments on commit 4d23be2

Please sign in to comment.