1
|
|
|
<?php namespace Anomaly\PreferencesModule\Preference\Contract; |
2
|
|
|
|
3
|
|
|
use Anomaly\PreferencesModule\Preference\PreferenceCollection; |
4
|
|
|
use Anomaly\PreferencesModule\Preference\PreferenceModel; |
5
|
|
|
use Anomaly\Streams\Platform\Addon\FieldType\FieldTypePresenter; |
6
|
|
|
use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Interface PreferenceRepositoryInterface |
10
|
|
|
* |
11
|
|
|
* @link http://pyrocms.com/ |
12
|
|
|
* @author PyroCMS, Inc. <[email protected]> |
13
|
|
|
* @author Ryan Thompson <[email protected]> |
14
|
|
|
*/ |
15
|
|
|
interface PreferenceRepositoryInterface extends EntryRepositoryInterface |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Return if a preference exists or not. |
20
|
|
|
* |
21
|
|
|
* @param $key |
22
|
|
|
* @return bool |
23
|
|
|
*/ |
24
|
|
|
public function has($key); |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Get a preference. |
28
|
|
|
* |
29
|
|
|
* @param $key |
30
|
|
|
* @return null|PreferenceInterface|PreferenceModel |
31
|
|
|
*/ |
32
|
|
|
public function get($key); |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Set a preferences value. |
36
|
|
|
* |
37
|
|
|
* @param $key |
38
|
|
|
* @param $value |
39
|
|
|
* @return bool |
40
|
|
|
*/ |
41
|
|
|
public function set($key, $value); |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Get a preference value presenter instance. |
45
|
|
|
* |
46
|
|
|
* @param $key |
47
|
|
|
* @param null $default |
48
|
|
|
* @return FieldTypePresenter|null |
49
|
|
|
*/ |
50
|
|
|
public function value($key, $default = null); |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Return the field type |
54
|
|
|
* presenter for a preference. |
55
|
|
|
* |
56
|
|
|
* @param $key |
57
|
|
|
* @return FieldTypePresenter|null |
58
|
|
|
*/ |
59
|
|
|
public function presenter($key); |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Find a preference by it's key |
63
|
|
|
* or return a new instance. |
64
|
|
|
* |
65
|
|
|
* @param $key |
66
|
|
|
* @return PreferenceInterface |
67
|
|
|
*/ |
68
|
|
|
public function findByKeyOrNew($key); |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Find all preferences with namespace. |
72
|
|
|
* |
73
|
|
|
* @param $namespace |
74
|
|
|
* @return PreferenceCollection |
75
|
|
|
*/ |
76
|
|
|
public function findAllByNamespace($namespace); |
77
|
|
|
} |
78
|
|
|
|