Skip to content

Commit b4b7b3c

Browse files
committed
- (API) Added new TransportInterface to the Postmaster_TransportModel with the getSendDate() and shouldSend() methods
1 parent 511c383 commit b4b7b3c

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
namespace Craft\Plugins\Postmaster\Interfaces;
3+
4+
interface TransportInterface {
5+
6+
public function getSendDate();
7+
8+
public function shouldSend();
9+
10+
}
Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,36 @@
11
<?php
22
namespace Craft;
33

4-
class Postmaster_TransportModel extends BaseModel
4+
use Craft\Plugins\Postmaster\Interfaces\TransportInterface;
5+
6+
class Postmaster_TransportModel extends BaseModel implements TransportInterface
57
{
8+
public function getSendDate()
9+
{
10+
$specific = new DateTime($this->sendDateSpecific);
11+
12+
if(!empty($this->sendDateRelative))
13+
{
14+
$specific->modify($this->sendDateRelative);
15+
}
16+
17+
return $specific;
18+
}
19+
20+
public function shouldSend()
21+
{
22+
return $this->getSendDate() <= new DateTime();
23+
}
24+
625
protected function defineAttributes()
726
{
827
return array(
928
'service' => AttributeType::Mixed,
1029
'settings' => AttributeType::Mixed,
11-
'data' => AttributeType::Mixed
30+
'data' => AttributeType::Mixed,
31+
'sendDateSpecific' => array(AttributeType::String, 'default' => null),
32+
'sendDateRelative' => AttributeType::String,
33+
'queueId' => array(AttributeType::Mixed, 'default' => false)
1234
);
1335
}
1436
}

0 commit comments

Comments
 (0)