forked from crisu83/yii-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAuthItemDataProvider.php
63 lines (56 loc) · 1.39 KB
/
AuthItemDataProvider.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* AuthItemDataProvider class file.
* @author Christoffer Niska <[email protected]>
* @copyright Copyright © Christoffer Niska 2012-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package auth.components
*/
/**
* Data provider for listing authorization items.
*/
class AuthItemDataProvider extends CDataProvider
{
/**
* @var string the item type (0=operation, 1=task, 2=role).
*/
public $type;
private $_items = array();
/**
* Sets the authorization items.
* @param CAuthItem[] $authItems the items.
*/
public function setAuthItems($authItems)
{
$this->_items = array_values($authItems);
}
/**
* Fetches the data from the persistent data storage.
* @return array list of data items
*/
protected function fetchData()
{
if (empty($this->_items) && $this->type !== null)
{
$authItems = Yii::app()->authManager->getAuthItems($this->type);
$this->setAuthItems($authItems);
}
return $this->_items;
}
/**
* Fetches the data item keys from the persistent data storage.
* @return array list of data item keys.
*/
protected function fetchKeys()
{
return array('name', 'description', 'type', 'bizrule', 'data');
}
/**
* Calculates the total number of data items.
* @return integer the total number of data items.
*/
protected function calculateTotalItemCount()
{
return count($this->_items);
}
}