-
Notifications
You must be signed in to change notification settings - Fork 56
/
Query.php
58 lines (48 loc) · 1.19 KB
/
Query.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
<?php
namespace luya\admin\folder;
use luya\admin\storage\QueryTrait;
use Yii;
use yii\base\BaseObject;
/**
* Storage Folders Querying.
*
* See the {{\luya\admin\storage\QueryTrait}} for more informations.
*
* @property \luya\admin\storage\BaseFileSystemStorage $storage The storage component
*
* @author Basil Suter <basil@nadar.io>
* @since 1.0.0
*/
class Query extends BaseObject
{
use QueryTrait;
private $_storage;
/**
* Singleton behavior for storage component getter.
*
* @return \luya\admin\storage\BaseFileSystemStorage
*/
public function getStorage()
{
if ($this->_storage === null) {
$this->_storage = Yii::$app->storage;
}
return $this->_storage;
}
public function getDataProvider()
{
return $this->storage->foldersArray;
}
public function getItemDataProvider($id)
{
return $this->storage->getFoldersArrayItem($id);
}
public function createItem(array $itemArray)
{
return Item::create($itemArray);
}
public function createIteratorObject(array $data)
{
return Yii::createObject(['class' => Iterator::class, 'data' => $data]);
}
}