PermissionsStorage.php
802 Bytes
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
namespace ACP\Access;
use AC\Storage\KeyValueFactory;
use AC\Storage\KeyValuePair;
use AC\Storage\Option;
final class PermissionsStorage
{
/**
* @var KeyValuePair
*/
private $storage;
public function __construct(KeyValueFactory $storage_factory)
{
$this->storage = $storage_factory->create('_acp_access_permissions');
}
public function retrieve(): Permissions
{
$permissions = $this->storage->get([
Option::OPTION_DEFAULT => [],
]);
return new Permissions($permissions ?: []);
}
public function exists(): bool
{
return false !== $this->storage->get();
}
public function save(Permissions $permissions): void
{
$this->storage->save($permissions->to_array());
}
}