forked from vespakoen/authority-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
authority.php
41 lines (33 loc) · 861 Bytes
/
authority.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
* Authority
*
* Authority is an authorization library for CodeIgniter 2+ and PHPActiveRecord
* This library is inspired by, and largely based off, Ryan Bates' CanCan gem
* for Ruby on Rails. It is not a 1:1 port, but the essentials are available.
* Please check out his work at http://github.com/ryanb/cancan/
*
* @package Authority
* @version 0.0.3
* @author Matthew Machuga
* @license MIT License
* @copyright 2011 Matthew Machuga
* @link http://github.com/machuga
*
**/
require 'ability.php';
require 'rule.php';
use Laravel\Auth;
class Authority extends Authority\Ability {
public static function initialize($user)
{
if(is_null($user)) return;
static::reset();
$initialize = Config::get('authority.initialize');
call_user_func($initialize, $user);
}
public static function as_user($user)
{
static::initialize($user);
}
}