Skip to content

Commit d6238f0

Browse files
committed
- (Bug Fix) Fixed a number of bugs in the parsing routine
1 parent 40f7134 commit d6238f0

File tree

6 files changed

+58
-14
lines changed

6 files changed

+58
-14
lines changed

core/components/BaseNotificationType.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,21 @@ public function parse(Array $data = array())
4040
'lastSent' => $this->notification->lastSent()
4141
), $data);
4242

43-
$this->notification->settings->parse($data);
43+
$this->notification
44+
->settings
45+
->parse($data);
4446

45-
$this->settings->parse($data);
47+
$this->settings
48+
->parse(array_merge($data, array('notification' => $this->notification)));
4649

47-
$this->notification->service->settings->parse(array_merge($data, array('settings' => $this->settings)));
50+
$this->notification
51+
->getNotificationSchedule()
52+
->settings
53+
->parse(array_merge($data, array('notification' => $this->notification)));
54+
55+
$this->notification
56+
->service
57+
->settings->parse(array_merge($data, array('notification' => $this->notification)));
4858
}
4959

5060
public function getInputHtml(Array $data = array())

core/components/BaseParcelType.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,21 @@ public function parse(Array $data = array())
2020

2121
$this->parcel
2222
->settings
23-
->parse($data);
24-
23+
->parse($data, false);
24+
2525
$this->settings
26-
->parse($data);
26+
->parse(array_merge($data, array('parcel' => $this->parcel)));
2727

2828
$this->parcel
2929
->getParcelSchedule()
3030
->settings
31-
->parse(array_merge($data, array('settings' => $this->settings)));
31+
->parse(array_merge($data, array('parcel' => $this->parcel)));
3232

3333
$this->parcel
3434
->service
3535
->settings
36-
->parse(array_merge($data, array('settings' => $this->settings)));
36+
->parse(array_merge($data, array('parcel' => $this->parcel)));
37+
3738
}
3839

3940
public function getInputHtml(Array $data = array())

core/interfaces/TransportInterface.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55

66
interface TransportInterface {
77

8+
public function getData($key = false);
9+
10+
public function setData($value);
11+
12+
public function addData($key, $value);
13+
814
public function shouldSend();
915

1016
public function getSendDate();

models/Postmaster_BaseSettingsModel.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
class Postmaster_BaseSettingsModel extends BaseModel implements ParseInterface
77
{
8-
public function parse(Array $data = array())
8+
public function parse(Array $data = array(), $recursive = true)
99
{
10-
$this->setAttributes($this->parseArray($this->getAttributes(), $data));
10+
$this->setAttributes($this->parseArray($this->getAttributes(), $data, $recursive));
1111

1212
return $this;
1313
}
@@ -17,13 +17,13 @@ public function render($value, Array $data = array())
1717
return craft()->templates->renderString($value, $data);
1818
}
1919

20-
public function parseArray($subject, Array $data = array())
20+
public function parseArray($subject, Array $data = array(), $recursive = true)
2121
{
2222
if(is_string($subject) && !empty($subject))
2323
{
2424
$subject = $this->render($subject, $data);
2525
}
26-
else if(is_array($subject) || is_object($subject))
26+
else if($recursive && (is_array($subject) || is_object($subject)))
2727
{
2828
foreach($subject as $index => $value)
2929
{

models/Postmaster_EmailModel.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ public function parse(Array $data = array())
1919
$this->$attr = craft()->templates->renderString($value, $data);
2020
}
2121
}
22-
23-
22+
2423
$oldPath = craft()->path->getTemplatesPath();
2524

2625
craft()->path->setTemplatesPath(CRAFT_TEMPLATES_PATH);

models/Postmaster_TransportModel.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,34 @@ public function now()
1111
return Carbon::now(craft()->getTimezone());
1212
}
1313

14+
public function getData($key = false)
15+
{
16+
if(!$key)
17+
{
18+
return $this->data;
19+
}
20+
21+
if(isset($this->data[$key]))
22+
{
23+
return $this->data[$key];
24+
}
25+
26+
return null;
27+
}
28+
29+
public function setData($value)
30+
{
31+
$this->data = $value;
32+
}
33+
34+
public function addData($key, $value)
35+
{
36+
$data = $this->data;
37+
$data[$key] = $value;
38+
39+
$this->data = $data;
40+
}
41+
1442
public function getSendDate()
1543
{
1644
if(!$this->sendDate || is_string($this->sendDate))

0 commit comments

Comments
 (0)