1 | 2 | simandl | <?php |
2 | | | |
3 | | | namespace Phem\Libraries\UI\Model; |
4 | | | |
5 | | | use Doctrine\Common\Annotations\AnnotationReader; |
6 | | | use Phem\Core\Collection; |
7 | | | use Phem\Core\Object; |
8 | | | use Phem\ToolSuite; |
9 | | | use ReflectionClass; |
10 | | | |
11 | | | /** |
12 | | | * @author Jakub PetrĹžĂlka <petrzilka@czweb.net> |
13 | | | */ |
14 | | | abstract class Workspace extends Object |
15 | | | { |
16 | | | |
17 | | | protected $backgroundColor; |
18 | | | protected $changes; |
19 | | | protected $currentVersion; |
20 | | | protected $scope; |
21 | | | protected $name; |
22 | | | |
23 | | | |
24 | | | /* public static function getInstance() |
25 | | | { |
26 | | | $reflectionClass = new ReflectionClass($this); |
27 | | | |
28 | | | $annotationReader = new AnnotationReader(); |
29 | | | $classAnnotations = $annotationReader |
30 | | | ->getClassAnnotations($reflectionClass); |
31 | | | |
32 | | | $workspace = null; |
33 | | | foreach ($classAnnotations as $annotation) |
34 | | | { |
35 | | | if ($annotation instanceof \Phem\Libraries\UI\Annotations\Scope) |
36 | | | { |
37 | | | switch (strtolower($annotation->value)) |
38 | | | { |
39 | | | case ScopeType::APPLICATION: |
40 | | | |
41 | | | case ScopeType::USER: |
42 | | | case ScopeType::SESSION: |
43 | | | case ScopeType::CONNECTION: |
44 | | | |
45 | | | } |
46 | | | break; |
47 | | | } |
48 | | | } |
49 | | | |
50 | | | if ($workspace == null) |
51 | | | { |
52 | | | return new self(); |
53 | | | } |
54 | | | }*/ |
55 | | | |
56 | | | function __construct() |
57 | | | { |
58 | | | $this->currentVersion = 0; |
59 | | | $this->changes = new Collection(); |
60 | | | } |
61 | | | |
62 | | | public function getBackgroundColor() |
63 | | | { |
64 | | | return $this->backgroundColor; |
65 | | | } |
66 | | | |
67 | | | public function setBackgroundColor($backgroundColor) |
68 | | | { |
69 | | | $this->backgroundColor = $backgroundColor; |
70 | | | } |
71 | | | |
72 | | | public function findControl($name) |
73 | | | { |
74 | | | $nameParts = explode("_", $name); |
75 | | | $superObject = $this; |
76 | | | foreach ($nameParts as $namePart) |
77 | | | { |
78 | | | $getter = "get".ucfirst($namePart); |
79 | | | $superObject = $superObject->$getter(); |
80 | | | } |
81 | | | return $superObject; |
82 | | | } |
83 | | | |
84 | | | public function getWindows() |
85 | | | { |
86 | | | |
87 | | | $windows = new Collection(); |
88 | | | |
89 | | | $methods = get_class_methods($this); |
90 | | | foreach ($methods as $method) |
91 | | | { |
92 | | | if ((ToolSuite::startsWith($method, 'get') !== false) && ($method != "getWindows")) |
93 | | | { |
94 | | | $val = $this->$method(); |
95 | | | if (is_a($val, '\Phem\Libraries\UI\Model\Window')) |
96 | | | { |
97 | | | $windows->put(lcfirst(substr($method, 3)), $val); |
98 | | | } |
99 | | | } |
100 | | | } |
101 | | | return $windows; |
102 | | | } |
103 | | | |
104 | | | public function getName() |
105 | | | { |
106 | | | return $this->name; |
107 | | | } |
108 | | | |
109 | | | public function setName($name) |
110 | | | { |
111 | | | $this->name = $name; |
112 | | | } |
113 | | | |
114 | | | public function getScope() |
115 | | | { |
116 | | | return $this->scope; |
117 | | | } |
118 | | | |
119 | | | public function setScope($scope) |
120 | | | { |
121 | | | $this->scope = $scope; |
122 | | | } |
123 | | | |
124 | | | public function getChanges() |
125 | | | { |
126 | | | return $this->changes; |
127 | | | } |
128 | | | |
129 | | | public function getCurrentVersion() |
130 | | | { |
131 | | | return $this->currentVersion; |
132 | | | } |
133 | | | |
134 | | | public function setChanges($changes) |
135 | | | { |
136 | | | $this->changes = $changes; |
137 | | | } |
138 | | | |
139 | | | public function setCurrentVersion($currentVersion) |
140 | | | { |
141 | | | $this->currentVersion = $currentVersion; |
142 | | | } |
143 | | | |
144 | | | } |