@@ -2,7 +2,6 @@ |
||
2 | 2 | namespace bedezign\yii2\audit\panels; |
3 | 3 | |
4 | 4 | use Yii; |
5 | -use bedezign\yii2\audit\models\AuditError; |
|
6 | 5 | use bedezign\yii2\audit\components\panels\DataStoragePanel; |
7 | 6 | use yii\data\ArrayDataProvider; |
8 | 7 |
@@ -22,7 +22,7 @@ |
||
22 | 22 | */ |
23 | 23 | public function getLabel() |
24 | 24 | { |
25 | - return $this->getName() . ' <small>(' . count($this->data) . ')</small>'; |
|
25 | + return $this->getName().' <small>('.count($this->data).')</small>'; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -35,8 +35,9 @@ |
||
35 | 35 | { |
36 | 36 | $this->module->registerPanel($this); |
37 | 37 | |
38 | - if (!is_array($this->data)) |
|
39 | - $this->data = []; |
|
38 | + if (!is_array($this->data)) { |
|
39 | + $this->data = []; |
|
40 | + } |
|
40 | 41 | |
41 | 42 | if (isset($data['error'])) { |
42 | 43 | $error = $this->module->exception($data['error']); |
@@ -2,10 +2,10 @@ |
||
2 | 2 | |
3 | 3 | namespace bedezign\yii2\audit\panels; |
4 | 4 | |
5 | +use Yii; |
|
5 | 6 | use bedezign\yii2\audit\components\panels\Panel; |
6 | 7 | use bedezign\yii2\audit\models\AuditTrail; |
7 | 8 | use bedezign\yii2\audit\models\AuditTrailSearch; |
8 | -use Yii; |
|
9 | 9 | use yii\grid\GridViewAsset; |
10 | 10 | |
11 | 11 | /** |
@@ -35,7 +35,7 @@ |
||
35 | 35 | */ |
36 | 36 | public function getLabel() |
37 | 37 | { |
38 | - return $this->getName() . ' <small>(' . count($this->_model->trails) . ')</small>'; |
|
38 | + return $this->getName().' <small>('.count($this->_model->trails).')</small>'; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -87,8 +87,9 @@ |
||
87 | 87 | public function cleanup($maxAge = null) |
88 | 88 | { |
89 | 89 | $maxAge = $maxAge !== null ? $maxAge : $this->maxAge; |
90 | - if ($maxAge === null) |
|
91 | - return false; |
|
90 | + if ($maxAge === null) { |
|
91 | + return false; |
|
92 | + } |
|
92 | 93 | return AuditTrail::deleteAll([ |
93 | 94 | '<=', 'created', date('Y-m-d 23:59:59', strtotime("-$maxAge days")) |
94 | 95 | ]); |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /* @var $panel bedezign\yii2\audit\panels\SoapPanel */ |
3 | 3 | |
4 | -use yii\bootstrap\Tabs; |
|
5 | -use yii\helpers\Html; |
|
6 | 4 | use bedezign\yii2\audit\components\Helper; |
5 | +use yii\bootstrap\Tabs; |
|
7 | 6 | use yii\helpers\ArrayHelper; |
7 | +use yii\helpers\Html; |
|
8 | 8 | use yii\helpers\VarDumper; |
9 | 9 | |
10 | 10 | $preformatted = ['class' => 'well', 'style' => 'overflow: auto; white-space: pre']; |
@@ -38,6 +38,6 @@ |
||
38 | 38 | unset($request['result']); |
39 | 39 | } |
40 | 40 | |
41 | -$tabs[] = [ 'label' => \Yii::t('audit', 'Info'), 'content' => $this->render('info_table', ['request' => $request]), 'active' => true ]; |
|
41 | +$tabs[] = ['label' => \Yii::t('audit', 'Info'), 'content' => $this->render('info_table', ['request' => $request]), 'active' => true]; |
|
42 | 42 | |
43 | 43 | echo Html::tag('h2', \Yii::t('audit', 'Request #{id}', ['id' => $index])), Tabs::widget(['items' => array_reverse($tabs)]); |
@@ -24,11 +24,12 @@ |
||
24 | 24 | |
25 | 25 | if (isset($request['result'])) { |
26 | 26 | $xml = Helper::formatAsXML($request['result']); |
27 | - if ($xml) |
|
28 | - $tabs[] = [ |
|
27 | + if ($xml) { |
|
28 | + $tabs[] = [ |
|
29 | 29 | 'label' => \Yii::t('audit', 'Result - XML'), |
30 | 30 | 'content' => Html::tag('div', $xml, $preformatted) |
31 | 31 | ]; |
32 | + } |
|
32 | 33 | |
33 | 34 | $tabs[] = [ |
34 | 35 | 'label' => \Yii::t('audit', 'Result'), |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | use yii\helpers\Html; |
4 | 4 | use yii\helpers\VarDumper; |
5 | -use yii\helpers\Url; |
|
6 | 5 | |
7 | 6 | |
8 | 7 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | if (isset($request['error']) && isset($request['error'][1])) { |
12 | 12 | $error = \bedezign\yii2\audit\models\AuditError::findOne($request['error'][1]); |
13 | - $request['error'] = Html::a('[' . $request['error'][0] . '] ' . $error->message, ['error/view', 'id' => $error->id]); |
|
13 | + $request['error'] = Html::a('['.$request['error'][0].'] '.$error->message, ['error/view', 'id' => $error->id]); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | ?> |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | if (is_array($value) || is_object($value)) |
32 | 32 | $value = \yii\helpers\ArrayHelper::toArray($value); |
33 | 33 | elseif ($name == 'duration') |
34 | - $value = number_format($value, 2) . 's'; |
|
34 | + $value = number_format($value, 2).'s'; |
|
35 | 35 | echo $name == 'error' ? $value : $formatter->asText(is_scalar($value) ? $value : VarDumper::dumpAsString($value)); |
36 | 36 | ?> |
37 | 37 | </td> |
@@ -28,10 +28,11 @@ |
||
28 | 28 | <th><?= Html::encode(\yii\helpers\Inflector::humanize($name)) ?></th> |
29 | 29 | <td> |
30 | 30 | <?php |
31 | - if (is_array($value) || is_object($value)) |
|
32 | - $value = \yii\helpers\ArrayHelper::toArray($value); |
|
33 | - elseif ($name == 'duration') |
|
34 | - $value = number_format($value, 2) . 's'; |
|
31 | + if (is_array($value) || is_object($value)) { |
|
32 | + $value = \yii\helpers\ArrayHelper::toArray($value); |
|
33 | + } elseif ($name == 'duration') { |
|
34 | + $value = number_format($value, 2) . 's'; |
|
35 | + } |
|
35 | 36 | echo $name == 'error' ? $value : $formatter->asText(is_scalar($value) ? $value : VarDumper::dumpAsString($value)); |
36 | 37 | ?> |
37 | 38 | </td> |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @link http://www.yiiframework.com/ |
|
4 | - * @copyright Copyright (c) 2008 Yii Software LLC |
|
5 | - * @license http://www.yiiframework.com/license/ |
|
6 | - */ |
|
3 | + * @link http://www.yiiframework.com/ |
|
4 | + * @copyright Copyright (c) 2008 Yii Software LLC |
|
5 | + * @license http://www.yiiframework.com/license/ |
|
6 | + */ |
|
7 | 7 | |
8 | 8 | namespace bedezign\yii2\audit; |
9 | 9 |
@@ -36,13 +36,15 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function export() |
38 | 38 | { |
39 | - if (!\Yii::$app) |
|
40 | - // Things like this can happen in tests etc, but it is too late for us to do anything about that. |
|
39 | + if (!\Yii::$app) { |
|
40 | + // Things like this can happen in tests etc, but it is too late for us to do anything about that. |
|
41 | 41 | return; |
42 | + } |
|
42 | 43 | |
43 | 44 | $module = $this->module; |
44 | - if (!$module->entry || empty($module->panels)) |
|
45 | - return; |
|
45 | + if (!$module->entry || empty($module->panels)) { |
|
46 | + return; |
|
47 | + } |
|
46 | 48 | |
47 | 49 | $entry = $module->entry; |
48 | 50 | |
@@ -53,11 +55,12 @@ discard block |
||
53 | 55 | $records = array_filter($records); |
54 | 56 | |
55 | 57 | if (!empty($records)) { |
56 | - if ($module->batchSave) |
|
57 | - $entry->addBatchData($records, false); |
|
58 | - else { |
|
59 | - foreach ($records as $type => $record) |
|
60 | - $entry->addData($type, $record, false); |
|
58 | + if ($module->batchSave) { |
|
59 | + $entry->addBatchData($records, false); |
|
60 | + } else { |
|
61 | + foreach ($records as $type => $record) { |
|
62 | + $entry->addData($type, $record, false); |
|
63 | + } |
|
61 | 64 | } |
62 | 65 | } |
63 | 66 | $this->messages = []; |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | |
96 | 96 | // heading |
97 | 97 | $n = count($panels); |
98 | - $this->stdout("Total $n " . ($n === 1 ? 'cleanup' : 'cleanups') . " to be applied:\n", Console::FG_YELLOW); |
|
99 | - $this->stdout("\t" . 'DATA CLEANUP TO DATETIME' . "\n"); |
|
100 | - $this->stdout("\t" . '---------------------------------------------' . "\n"); |
|
98 | + $this->stdout("Total $n ".($n === 1 ? 'cleanup' : 'cleanups')." to be applied:\n", Console::FG_YELLOW); |
|
99 | + $this->stdout("\t".'DATA CLEANUP TO DATETIME'."\n"); |
|
100 | + $this->stdout("\t".'---------------------------------------------'."\n"); |
|
101 | 101 | |
102 | 102 | // audit panels |
103 | 103 | foreach ($panels as $id) { |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | $dots = str_repeat('.', 24 - strlen($id)); |
108 | 108 | if ($age !== null) { |
109 | 109 | $date = date('Y-m-d 23:59:59', strtotime("-$age days")); |
110 | - $this->stdout("\t" . $id . ' ' . $dots . ' ' . $date . "\n"); |
|
110 | + $this->stdout("\t".$id.' '.$dots.' '.$date."\n"); |
|
111 | 111 | } else { |
112 | - $this->stdout("\t" . $id . ' ' . $dots . ' no maxAge, skipping' . "\n"); |
|
112 | + $this->stdout("\t".$id.' '.$dots.' no maxAge, skipping'."\n"); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | if ($entry) { |
118 | 118 | $maxAge = $maxAge !== null ? $maxAge : $audit->maxAge; |
119 | 119 | $date = $maxAge !== null ? date('Y-m-d 23:59:59', strtotime("-$maxAge days")) : 'no maxAge, skipping'; |
120 | - $this->stdout("\t" . 'AuditEntry .............. ' . $date . "\n"); |
|
120 | + $this->stdout("\t".'AuditEntry .............. '.$date."\n"); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | $this->stdout("\n"); |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | $count = AuditEntry::deleteAll(['<=', 'created', $date]); |
143 | 143 | if ($count !== false) { |
144 | 144 | $time = microtime(true) - $start; |
145 | - $this->stdout("\n*** cleaned AuditEntry (records: " . $count . ",time: " . sprintf("%.3f", $time) . "s)\n", Console::FG_GREEN); |
|
145 | + $this->stdout("\n*** cleaned AuditEntry (records: ".$count.",time: ".sprintf("%.3f", $time)."s)\n", Console::FG_GREEN); |
|
146 | 146 | return true; |
147 | 147 | } |
148 | 148 | $time = microtime(true) - $start; |
149 | - $this->stdout("\n*** failed to clean AuditEntry (time: " . sprintf("%.3f", $time) . "s)\n", Console::FG_RED); |
|
149 | + $this->stdout("\n*** failed to clean AuditEntry (time: ".sprintf("%.3f", $time)."s)\n", Console::FG_RED); |
|
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | $count = $panel->cleanup($maxAge); |
172 | 172 | if ($count !== false) { |
173 | 173 | $time = microtime(true) - $start; |
174 | - $this->stdout("\n*** cleaned $id (records: " . $count . ", time: " . sprintf("%.3f", $time) . "s)\n", Console::FG_GREEN); |
|
174 | + $this->stdout("\n*** cleaned $id (records: ".$count.", time: ".sprintf("%.3f", $time)."s)\n", Console::FG_GREEN); |
|
175 | 175 | return true; |
176 | 176 | } |
177 | 177 | $time = microtime(true) - $start; |
178 | - $this->stdout("\n*** failed to clean $id (time: " . sprintf("%.3f", $time) . "s)\n", Console::FG_RED); |
|
178 | + $this->stdout("\n*** failed to clean $id (time: ".sprintf("%.3f", $time)."s)\n", Console::FG_RED); |
|
179 | 179 | return false; |
180 | 180 | } |
181 | 181 | |
@@ -207,13 +207,13 @@ discard block |
||
207 | 207 | ]; |
208 | 208 | $message = [ |
209 | 209 | 'subject' => Yii::t('audit', 'Audit Error in Audit Entry #{entry_id}', $params), |
210 | - 'text' => Yii::t('audit', '{message}' . "\n" . 'in {file} on line {line}.' . "\n" . '-- {url}', $params), |
|
210 | + 'text' => Yii::t('audit', '{message}'."\n".'in {file} on line {line}.'."\n".'-- {url}', $params), |
|
211 | 211 | 'html' => Yii::t('audit', '<b>{message}</b><br />in <i>{file}</i> on line <i>{line}</i>.<br/>-- {link}', $params), |
212 | 212 | ]; |
213 | 213 | |
214 | 214 | // send email |
215 | 215 | Yii::$app->mailer->compose() |
216 | - ->setFrom([$email => 'Audit :: ' . Yii::$app->name]) |
|
216 | + ->setFrom([$email => 'Audit :: '.Yii::$app->name]) |
|
217 | 217 | ->setTo($email) |
218 | 218 | ->setSubject($message['subject']) |
219 | 219 | ->setTextBody($message['text']) |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | { |
92 | 92 | $data = ArrayHelper::toArray($data); |
93 | 93 | if ($simplify) |
94 | - array_walk($data, function (&$value) { |
|
94 | + array_walk($data, function(&$value) { |
|
95 | 95 | if (is_array($value) && count($value) == 1) $value = reset($value); |
96 | 96 | }); |
97 | 97 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | if (is_object($value)) { |
168 | 168 | $class = get_class($value); |
169 | 169 | // By default we just mention the object type |
170 | - $args[$name] = 'Object(' . $class . ')'; |
|
170 | + $args[$name] = 'Object('.$class.')'; |
|
171 | 171 | |
172 | 172 | if ($recurseDepth > 0) { |
173 | 173 | // Make sure to limit the toArray to non recursive, it's much to easy to get stuck in an infinite loop |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | $hash = bcadd(sprintf('%u', crc32($data)), 0x100000000); |
199 | 199 | $str = ''; |
200 | 200 | do { |
201 | - $str = $map[bcmod($hash, 62)] . $str; |
|
201 | + $str = $map[bcmod($hash, 62)].$str; |
|
202 | 202 | $hash = bcdiv($hash, 62); |
203 | 203 | } while ($hash >= 1); |
204 | 204 | return $str; |
@@ -23,8 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public static function serialize($data, $compact = true) |
25 | 25 | { |
26 | - if ($compact) |
|
27 | - $data = self::compact($data); |
|
26 | + if ($compact) { |
|
27 | + $data = self::compact($data); |
|
28 | + } |
|
28 | 29 | |
29 | 30 | $data = serialize($data); |
30 | 31 | $data = self::compress($data); |
@@ -39,19 +40,22 @@ discard block |
||
39 | 40 | */ |
40 | 41 | public static function unserialize($data) |
41 | 42 | { |
42 | - if (is_resource($data)) |
|
43 | - // For some databases (like Postgres) binary columns return as a resource, fetch the content first |
|
43 | + if (is_resource($data)) { |
|
44 | + // For some databases (like Postgres) binary columns return as a resource, fetch the content first |
|
44 | 45 | $data = stream_get_contents($data, -1, 0); |
46 | + } |
|
45 | 47 | |
46 | 48 | $originalData = $data; |
47 | 49 | $data = self::uncompress($data); |
48 | 50 | |
49 | - if ($data === false) |
|
50 | - $data = $originalData; |
|
51 | + if ($data === false) { |
|
52 | + $data = $originalData; |
|
53 | + } |
|
51 | 54 | |
52 | 55 | $data = @unserialize($data); |
53 | - if ($data === false) |
|
54 | - $data = $originalData; |
|
56 | + if ($data === false) { |
|
57 | + $data = $originalData; |
|
58 | + } |
|
55 | 59 | |
56 | 60 | return $data; |
57 | 61 | } |
@@ -63,8 +67,9 @@ discard block |
||
63 | 67 | */ |
64 | 68 | public static function compress($data) |
65 | 69 | { |
66 | - if (Audit::getInstance()->compressData) |
|
67 | - $data = gzcompress($data); |
|
70 | + if (Audit::getInstance()->compressData) { |
|
71 | + $data = gzcompress($data); |
|
72 | + } |
|
68 | 73 | return $data; |
69 | 74 | } |
70 | 75 | |
@@ -90,15 +95,17 @@ discard block |
||
90 | 95 | public static function compact($data, $simplify = false, $threshold = 512) |
91 | 96 | { |
92 | 97 | $data = ArrayHelper::toArray($data); |
93 | - if ($simplify) |
|
94 | - array_walk($data, function (&$value) { |
|
98 | + if ($simplify) { |
|
99 | + array_walk($data, function (&$value) { |
|
95 | 100 | if (is_array($value) && count($value) == 1) $value = reset($value); |
101 | + } |
|
96 | 102 | }); |
97 | 103 | |
98 | 104 | $tooBig = []; |
99 | - foreach ($data as $index => $value) |
|
100 | - if (strlen(serialize($value)) > $threshold) |
|
105 | + foreach ($data as $index => $value) { |
|
106 | + if (strlen(serialize($value)) > $threshold) |
|
101 | 107 | $tooBig[] = $index; |
108 | + } |
|
102 | 109 | |
103 | 110 | if (count($tooBig)) { |
104 | 111 | $data = array_diff_key($data, array_flip($tooBig)); |
@@ -117,8 +124,9 @@ discard block |
||
117 | 124 | { |
118 | 125 | $trace = debug_backtrace(); |
119 | 126 | array_pop($trace); // remove the last trace since it would be the entry script, not very useful |
120 | - if ($skip > 0) |
|
121 | - $trace = array_slice($trace, $skip); |
|
127 | + if ($skip > 0) { |
|
128 | + $trace = array_slice($trace, $skip); |
|
129 | + } |
|
122 | 130 | return self::cleanupTrace($trace); |
123 | 131 | } |
124 | 132 | |
@@ -130,8 +138,9 @@ discard block |
||
130 | 138 | */ |
131 | 139 | public static function cleanupTrace($trace) |
132 | 140 | { |
133 | - if (!is_array($trace)) |
|
134 | - return []; |
|
141 | + if (!is_array($trace)) { |
|
142 | + return []; |
|
143 | + } |
|
135 | 144 | |
136 | 145 | foreach ($trace as $n => $call) { |
137 | 146 | $call['file'] = isset($call['file']) ? $call['file'] : 'unknown'; |
@@ -140,14 +149,18 @@ discard block |
||
140 | 149 | $call['file'] = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $call['file']); |
141 | 150 | |
142 | 151 | // XDebug |
143 | - if (isset($call['params'])) unset($call['params']); |
|
152 | + if (isset($call['params'])) { |
|
153 | + unset($call['params']); |
|
154 | + } |
|
144 | 155 | |
145 | 156 | // Trace entry contains the class instance, also compact and include this |
146 | - if (isset($call['object'])) |
|
147 | - $call['object'] = current(self::cleanupTraceArguments([$call['object']])); |
|
157 | + if (isset($call['object'])) { |
|
158 | + $call['object'] = current(self::cleanupTraceArguments([$call['object']])); |
|
159 | + } |
|
148 | 160 | |
149 | - if (isset($call['args'])) |
|
150 | - $call['args'] = self::cleanupTraceArguments($call['args']); |
|
161 | + if (isset($call['args'])) { |
|
162 | + $call['args'] = self::cleanupTraceArguments($call['args']); |
|
163 | + } |
|
151 | 164 | |
152 | 165 | $trace[$n] = $call; |
153 | 166 | } |
@@ -176,10 +189,11 @@ discard block |
||
176 | 189 | $args[$name] = $object; |
177 | 190 | } |
178 | 191 | } else if (is_array($value)) { |
179 | - if ($recurseDepth > 0) |
|
180 | - $args[$name] = self::cleanupTraceArguments($value, $recurseDepth - 1); |
|
181 | - else |
|
182 | - $args[$name] = 'Array'; |
|
192 | + if ($recurseDepth > 0) { |
|
193 | + $args[$name] = self::cleanupTraceArguments($value, $recurseDepth - 1); |
|
194 | + } else { |
|
195 | + $args[$name] = 'Array'; |
|
196 | + } |
|
183 | 197 | } |
184 | 198 | } |
185 | 199 | return $args; |
@@ -212,8 +226,9 @@ discard block |
||
212 | 226 | public static function formatAsQuery($data) |
213 | 227 | { |
214 | 228 | $data = rawurldecode($data); |
215 | - if (!preg_match('/^([\w\d\-\[\]]+(=[^&]*)?(&[\w\d\-\[\]]+(=[^&]*)?)*)?$/', $data)) |
|
216 | - return null; |
|
229 | + if (!preg_match('/^([\w\d\-\[\]]+(=[^&]*)?(&[\w\d\-\[\]]+(=[^&]*)?)*)?$/', $data)) { |
|
230 | + return null; |
|
231 | + } |
|
217 | 232 | |
218 | 233 | $result = []; |
219 | 234 | parse_str($data, $result); |
@@ -241,8 +256,9 @@ discard block |
||
241 | 256 | $doc = new \DOMDocument('1.0'); |
242 | 257 | $doc->preserveWhiteSpace = false; |
243 | 258 | $doc->formatOutput = true; |
244 | - if (@$doc->loadXML($data)) |
|
245 | - return htmlentities($doc->saveXML(), ENT_COMPAT, 'UTF-8'); |
|
259 | + if (@$doc->loadXML($data)) { |
|
260 | + return htmlentities($doc->saveXML(), ENT_COMPAT, 'UTF-8'); |
|
261 | + } |
|
246 | 262 | return null; |
247 | 263 | } |
248 | 264 | |
@@ -253,14 +269,16 @@ discard block |
||
253 | 269 | */ |
254 | 270 | public static function formatAsHTML($data) |
255 | 271 | { |
256 | - if ($data == strip_tags($data) || strtolower(substr(ltrim($data), 0, 5)) == '<?xml') |
|
257 | - return null; |
|
272 | + if ($data == strip_tags($data) || strtolower(substr(ltrim($data), 0, 5)) == '<?xml') { |
|
273 | + return null; |
|
274 | + } |
|
258 | 275 | |
259 | 276 | $doc = new \DOMDocument('1.0'); |
260 | 277 | $doc->preserveWhiteSpace = false; |
261 | 278 | $doc->formatOutput = true; |
262 | - if (@$doc->loadHTML($data)) |
|
263 | - return htmlentities($doc->saveHTML(), ENT_COMPAT, 'UTF-8'); |
|
279 | + if (@$doc->loadHTML($data)) { |
|
280 | + return htmlentities($doc->saveHTML(), ENT_COMPAT, 'UTF-8'); |
|
281 | + } |
|
264 | 282 | return null; |
265 | 283 | } |
266 | 284 | } |
267 | 285 | \ No newline at end of file |
@@ -80,7 +80,7 @@ |
||
80 | 80 | return $this->_data['result'] = parent::__doRequest($request, $location, $action, $version, $one_way); |
81 | 81 | } |
82 | 82 | |
83 | - public function __setCookie ($name, $value = null) |
|
83 | + public function __setCookie($name, $value = null) |
|
84 | 84 | { |
85 | 85 | if (!isset($this->_data['cookies'])) |
86 | 86 | $this->_data['cookies'] = []; |
@@ -14,8 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | try { |
16 | 16 | parent::__construct($wsdl, $options); |
17 | - } |
|
18 | - catch (\SoapFault $e) { |
|
17 | + } catch (\SoapFault $e) { |
|
19 | 18 | // Catches errors like being unable to read the WSDL and so on |
20 | 19 | $this->logSoapFault($e); |
21 | 20 | throw $e; |
@@ -46,22 +45,24 @@ discard block |
||
46 | 45 | try { |
47 | 46 | $result = parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers); |
48 | 47 | $this->_data['duration'] = microtime(true) - $started; |
49 | - if ($output_headers) |
|
50 | - $this->_data['output_headers'] = (array) $output_headers; |
|
48 | + if ($output_headers) { |
|
49 | + $this->_data['output_headers'] = (array) $output_headers; |
|
50 | + } |
|
51 | 51 | |
52 | - if (is_soap_fault($result)) |
|
53 | - // Cover non-exception variant |
|
52 | + if (is_soap_fault($result)) { |
|
53 | + // Cover non-exception variant |
|
54 | 54 | return $this->logSoapFault($result); |
55 | + } |
|
55 | 56 | |
56 | 57 | $this->_data['result_object'] = $result; |
57 | 58 | $this->finalize(); |
58 | 59 | |
59 | 60 | return $result; |
60 | - } |
|
61 | - catch (\Exception $error) { |
|
61 | + } catch (\Exception $error) { |
|
62 | 62 | $this->_data['duration'] = microtime(true) - $started; |
63 | - if ($output_headers) |
|
64 | - $this->_data['output_headers'] = (array) $output_headers; |
|
63 | + if ($output_headers) { |
|
64 | + $this->_data['output_headers'] = (array) $output_headers; |
|
65 | + } |
|
65 | 66 | |
66 | 67 | $this->logSoapFault($error); |
67 | 68 | throw $error; |
@@ -82,8 +83,9 @@ discard block |
||
82 | 83 | |
83 | 84 | public function __setCookie ($name, $value = null) |
84 | 85 | { |
85 | - if (!isset($this->_data['cookies'])) |
|
86 | - $this->_data['cookies'] = []; |
|
86 | + if (!isset($this->_data['cookies'])) { |
|
87 | + $this->_data['cookies'] = []; |
|
88 | + } |
|
87 | 89 | $this->_data['cookies'][$name] = $value; |
88 | 90 | |
89 | 91 | parent::__setCookie($name, $value); |
@@ -99,7 +101,8 @@ discard block |
||
99 | 101 | protected function finalize() |
100 | 102 | { |
101 | 103 | $_panel = Audit::getInstance()->getPanel('audit/soap'); |
102 | - if ($_panel) |
|
103 | - $_panel->logSoapRequest($this->_data); |
|
104 | + if ($_panel) { |
|
105 | + $_panel->logSoapRequest($this->_data); |
|
106 | + } |
|
104 | 107 | } |
105 | 108 | } |
106 | 109 | \ No newline at end of file |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Console compatible error handler |
|
4 | - */ |
|
3 | + * Console compatible error handler |
|
4 | + */ |
|
5 | 5 | |
6 | 6 | namespace bedezign\yii2\audit\components\console; |
7 | 7 |