1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Something between Atom and Sand |
4
|
|
|
* |
5
|
|
|
* @author Vitex <[email protected]> |
6
|
|
|
* @copyright 2009-2019 [email protected] (G) |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Ease; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Description of Molecule |
13
|
|
|
* |
14
|
|
|
* @author vitex |
15
|
|
|
*/ |
16
|
|
|
class Molecule extends Atom |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Here Live Shared Object |
21
|
|
|
* |
22
|
|
|
* @var Shared |
23
|
|
|
*/ |
24
|
|
|
public $easeShared = null; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* |
28
|
|
|
* @var Logger\Regent |
29
|
|
|
*/ |
30
|
|
|
private $logger; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Molecule Can Log and Use Shared |
34
|
|
|
*/ |
35
|
1 |
|
public function __construct() |
36
|
|
|
{ |
37
|
1 |
|
$this->easeShared = Shared::singleton(); |
38
|
1 |
|
$this->logger = $this->easeShared->logger(); |
39
|
|
|
|
40
|
1 |
|
$this->setObjectName(); |
41
|
1 |
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Nastaví jméno objektu. |
45
|
|
|
* |
46
|
|
|
* @param string $objectName |
47
|
|
|
* |
48
|
|
|
* @return string Jméno objektu |
49
|
|
|
*/ |
50
|
1 |
|
public function setObjectName($objectName = null) |
51
|
|
|
{ |
52
|
1 |
|
if (empty($objectName)) { |
53
|
1 |
|
$this->objectName = get_class($this); |
54
|
|
|
} else { |
55
|
|
|
$this->objectName = $objectName; |
56
|
|
|
} |
57
|
|
|
|
58
|
1 |
|
return $this->objectName; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Vrací jméno objektu. |
63
|
|
|
* |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
|
|
public function getObjectName() |
67
|
|
|
{ |
68
|
|
|
return $this->objectName; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Set up one of properties |
73
|
|
|
* |
74
|
|
|
* @param array $options array of given properties |
75
|
|
|
* @param string $name name of property to process |
76
|
|
|
* @param string $constant load default property value from constant |
77
|
|
|
*/ |
78
|
|
|
public function setupProperty($options, $name, $constant = null) |
79
|
|
|
{ |
80
|
|
|
if (isset($options[$name])) { |
81
|
|
|
$this->$name = $options[$name]; |
82
|
|
|
} else { |
83
|
|
|
if (is_null($this->$name) && !empty($constant) && defined($constant)) { |
84
|
|
|
$this->$name = constant($constant); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Zapíše zprávu do logu. |
91
|
|
|
* |
92
|
|
|
* @param string $message zpráva |
93
|
|
|
* @param string $type typ zprávy (info|warning|success|error|*) |
94
|
|
|
* |
95
|
|
|
* @return bool byl report zapsán ? |
96
|
|
|
*/ |
97
|
|
|
public function addToLog($message, $type = 'message') |
98
|
|
|
{ |
99
|
|
|
$logged = false; |
100
|
|
|
if (isset($this->logger) && is_object($this->logger)) { |
101
|
|
|
$this->logger->addToLog($this->getObjectName(), $message, $type); |
102
|
|
|
} else { |
103
|
|
|
$logged = Shared::logger()->addToLog($this->getObjectName(), |
104
|
|
|
$message, $type); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
return $logged; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Přidá zprávu do sdíleného zásobníku pro zobrazení uživateli. |
112
|
|
|
* |
113
|
|
|
* @param string $message Text zprávy |
114
|
|
|
* @param string $type Fronta zpráv (warning|info|error|success) |
115
|
|
|
* |
116
|
|
|
* @return |
117
|
|
|
*/ |
118
|
|
|
public function addStatusMessage($message, $type = 'info') |
119
|
|
|
{ |
120
|
|
|
return $this->easeShared->takeMessage(new Logger\Message($message, |
|
|
|
|
121
|
|
|
$type, get_class($this))); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Obtain Status Messages |
126
|
|
|
* |
127
|
|
|
* @param bool $clean Remove messages from strack ? |
128
|
|
|
* |
129
|
|
|
* @return array |
130
|
|
|
*/ |
131
|
|
|
public function getStatusMessages($clean = false) |
132
|
|
|
{ |
133
|
|
|
$messages = $this->easeShared->getStatusMessages(); |
134
|
|
|
if ($clean) { |
135
|
|
|
$this->easeShared->cleanMessages(); |
136
|
|
|
} |
137
|
|
|
return $messages; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
} |
141
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.