Skip to content

Commit 1a7ccbb

Browse files
committed
Updates
1 parent d6238f0 commit 1a7ccbb

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

core/services/HttpRequestService.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,26 +67,36 @@ public function send(Postmaster_TransportModel $model)
6767
$response = (string) $e->getResponse()->getBody();
6868
$json = json_decode($response);
6969

70+
$model->addData('responseString', $response);
71+
7072
if(is_object($json) && isset($json->errors))
7173
{
7274
if(!is_array($json->errors))
7375
{
7476
$json->errors = (array) $json->errors;
7577
}
7678

79+
$model->addData('responseJson', $json);
80+
7781
return $this->failed($model, 400, $json->errors);
7882
}
7983
else
8084
{
85+
$model->addData('responseJson', array($response));
86+
8187
return $this->failed($model, 400, array($response));
8288
}
8389

8490
}
8591
catch(\Exception $e)
8692
{
8793
$error = $e->getMessage();
94+
$json = !is_array($error) ? array('title' => $error) : $error;
95+
96+
$model->addData('responseString', $error);
97+
$model->addData('responseJson', $json);
8898

89-
return $this->failed($model, 400, !is_array($error) ? array($error) : $error);
99+
return $this->failed($model, 400, $json);
90100
}
91101
}
92102

models/Postmaster_BaseSettingsModel.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,23 @@ public function parseArray($subject, Array $data = array(), $recursive = true)
2323
{
2424
$subject = $this->render($subject, $data);
2525
}
26-
else if($recursive && (is_array($subject) || is_object($subject)))
26+
else if($recursive && is_array($subject) || is_object($subject))
2727
{
2828
foreach($subject as $index => $value)
2929
{
3030
$subject[$index] = $this->parseArray($value, $data);
3131
}
3232
}
33+
else if(!$recursive && is_array($subject) || is_object($subject))
34+
{
35+
foreach($subject as $index => $value)
36+
{
37+
if(is_string($value) && !empty($value))
38+
{
39+
$subject[$index] = $this->render($value, $data);
40+
}
41+
}
42+
}
3343

3444
return $subject;
3545
}

models/Postmaster_HttpRequestServiceSettingsModel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public function parse(Array $data = array())
2626
}
2727

2828
$this->files = $parsedFiles;
29-
30-
parent::parse($data);
29+
30+
$this->setAttributes($this->parseArray($this->getAttributes(), $data, false));
3131

3232
return $this;
3333
}

0 commit comments

Comments
 (0)