1 | <?php |
||
4 | class StorageSelection |
||
5 | { |
||
6 | |||
7 | protected $providerId = 'defaultProvider'; |
||
8 | protected $id; |
||
9 | protected $name; |
||
10 | protected $impl; |
||
11 | protected $metadata = array(); |
||
12 | |||
13 | 18 | public function __construct($impl, $id=null, $name=null, array $metadata=array()) |
|
14 | { |
||
15 | 18 | $this->impl = $impl; |
|
16 | 18 | $this->id = $id; |
|
17 | 18 | $this->name = $name; |
|
18 | 18 | $this->metadata = $metadata; |
|
19 | 18 | } |
|
20 | |||
21 | public function addMetadata($key, $value) |
||
25 | |||
26 | public function setMetadata(array $metadata) |
||
30 | |||
31 | 2 | public function getMetadata($key) |
|
32 | { |
||
33 | 2 | if (!isset($this->metadata[$key])) { |
|
34 | 2 | return null; |
|
35 | } |
||
36 | |||
37 | return $this->metadata[$key]; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @return StorageSelection |
||
42 | */ |
||
43 | 1 | public function setProviderId($providerId) |
|
44 | { |
||
45 | 1 | $this->providerId = $providerId; |
|
46 | |||
47 | 1 | return $this; |
|
48 | } |
||
49 | |||
50 | 1 | public function getProviderId() |
|
54 | |||
55 | 20 | public function getId() |
|
59 | |||
60 | 1 | public function getName() |
|
64 | |||
65 | 5 | public function getImpl() |
|
76 | |||
77 | public function prePersist() |
||
78 | { |
||
79 | if ($this->impl instanceof \SplFileInfo) { |
||
80 | |||
81 | //TODO some sort of serializable wrapper? |
||
82 | $this->impl = array( |
||
83 | 'class'=>get_class($this->impl), |
||
84 | 'args'=>array($this->impl->getRealPath()) |
||
85 | ); |
||
86 | } |
||
87 | } |
||
88 | |||
89 | public function toArray() |
||
93 | |||
94 | public function __toString() |
||
95 | { |
||
96 | return http_build_query ($this->toArray()); |
||
97 | } |
||
98 | |||
99 | } |
||
100 |