Skip to content

Commit 9b89cfb

Browse files
authored
Merge pull request #683 from favicode/fix/logging_condition
Fix for real time logging (create new response condition) issue #682
2 parents 3d9e121 + 07fa0a4 commit 9b89cfb

File tree

2 files changed

+29
-34
lines changed

2 files changed

+29
-34
lines changed

Controller/Adminhtml/FastlyCdn/Logging/CreateEndpoint.php

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
class CreateEndpoint extends Action
3636
{
3737
const ADMIN_RESOURCE = 'Magento_Config::config';
38-
38+
3939
/**
4040
* @var Http
4141
*/
@@ -110,16 +110,16 @@ public function execute()
110110
$clone,
111111
$this->getRequest()->getParam('condition_name'),
112112
$this->getRequest()->getParam('apply_if'),
113-
$this->getRequest()->getParam('condition_priority'),
114-
$this->getRequest()->getParam('response_condition')
113+
$this->getRequest()->getParam('condition_priority')
115114
);
116115

117116
$params = array_merge(
118117
$this->getRequest()->getParam('log_endpoint'),
119118
['response_condition' => $condition]
120119
);
120+
$params = array_filter($params);
121121

122-
$endpoint = $this->api->createLogEndpoint($clone->number, $endpointType, array_filter($params));
122+
$endpoint = $this->api->createLogEndpoint($clone->number, $endpointType, $params);
123123

124124
if (!$endpoint) {
125125
return $result->setData([
@@ -156,23 +156,21 @@ public function execute()
156156
* @param $conditionName
157157
* @param $applyIf
158158
* @param $conditionPriority
159-
* @param $selCondition
160-
* @return mixed
159+
* @return string|null
161160
* @throws \Magento\Framework\Exception\LocalizedException
162161
*/
163-
private function createCondition($clone, $conditionName, $applyIf, $conditionPriority, $selCondition)
162+
private function createCondition($clone, $conditionName, $applyIf, $conditionPriority)
164163
{
165-
if ($conditionName == $selCondition && !empty($selCondition) &&
166-
!$this->api->getCondition($clone->number, $conditionName)) {
167-
$condition = [
168-
'name' => $conditionName,
169-
'statement' => $applyIf,
170-
'type' => 'RESPONSE',
171-
'priority' => $conditionPriority
172-
];
173-
$createCondition = $this->api->createCondition($clone->number, $condition);
174-
return $createCondition->name;
164+
if (!$conditionName || !$applyIf || !$conditionPriority) {
165+
return null;
175166
}
176-
return $selCondition;
167+
$condition = [
168+
'name' => $conditionName,
169+
'statement' => $applyIf,
170+
'type' => 'RESPONSE',
171+
'priority' => $conditionPriority
172+
];
173+
$createCondition = $this->api->createCondition($clone->number, $condition);
174+
return $createCondition->name;
177175
}
178176
}

Controller/Adminhtml/FastlyCdn/Logging/UpdateEndpoint.php

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ public function execute()
111111
$clone,
112112
$this->getRequest()->getParam('condition_name'),
113113
$this->getRequest()->getParam('apply_if'),
114-
$this->getRequest()->getParam('condition_priority'),
115-
$this->getRequest()->getParam('response_condition')
114+
$this->getRequest()->getParam('condition_priority')
116115
);
117116

118117
$params = array_merge(
@@ -162,23 +161,21 @@ public function execute()
162161
* @param $conditionName
163162
* @param $applyIf
164163
* @param $conditionPriority
165-
* @param $selCondition
166-
* @return mixed
164+
* @return string|null
167165
* @throws \Magento\Framework\Exception\LocalizedException
168166
*/
169-
private function createCondition($clone, $conditionName, $applyIf, $conditionPriority, $selCondition)
167+
private function createCondition($clone, $conditionName, $applyIf, $conditionPriority)
170168
{
171-
if ($conditionName == $selCondition && !empty($selCondition) &&
172-
!$this->api->getCondition($clone->number, $conditionName)) {
173-
$condition = [
174-
'name' => $conditionName,
175-
'statement' => $applyIf,
176-
'type' => 'RESPONSE',
177-
'priority' => $conditionPriority
178-
];
179-
$createCondition = $this->api->createCondition($clone->number, $condition);
180-
return $createCondition->name;
169+
if (!$conditionName || !$applyIf || !$conditionPriority) {
170+
return null;
181171
}
182-
return $selCondition;
172+
$condition = [
173+
'name' => $conditionName,
174+
'statement' => $applyIf,
175+
'type' => 'RESPONSE',
176+
'priority' => $conditionPriority
177+
];
178+
$createCondition = $this->api->createCondition($clone->number, $condition);
179+
return $createCondition->name;
183180
}
184181
}

0 commit comments

Comments
 (0)