File tree 3 files changed +49
-1
lines changed
3 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ and queue a new one by storing the correct data:
63
63
- Third arguments is an array of options, possible options are
64
64
* ` subject ` : Email's subject
65
65
* ` send_at ` : date time sting representing the time this email should be sent at (in UTC)
66
- * ` template ` : the name of the element to use as template for the email message
66
+ * ` template ` : the name of the element to use as template for the email message. (maximum supported length is 100 chars)
67
67
* ` layout ` : the name of the layout to be used to wrap email message
68
68
* ` format ` : Type of template to use (html, text or both)
69
69
* ` headers ` : A key-value list of headers to send in the email
Original file line number Diff line number Diff line change
1
+ <?php
2
+ use Migrations \AbstractMigration ;
3
+ use Phinx \Db \Adapter \MysqlAdapter ;
4
+
5
+ class AlterTemplateToEmailQueue extends AbstractMigration
6
+ {
7
+ /**
8
+ * Up Method
9
+ *
10
+ * More information on this method is available here:
11
+ * http://docs.phinx.org/en/latest/migrations.html#the-up-method
12
+ *
13
+ * @return void
14
+ */
15
+ public function up ()
16
+ {
17
+ $ this ->table ('email_queue ' )
18
+ ->changeColumn ('template ' , 'string ' , [
19
+ 'limit ' => 100 ,
20
+ ])
21
+ ->update ();
22
+ }
23
+
24
+ /**
25
+ * Down Method
26
+ *
27
+ * More information on this method is available here:
28
+ * http://docs.phinx.org/en/latest/migrations.html#the-down-method
29
+ *
30
+ * @return void
31
+ */
32
+ public function down ()
33
+ {
34
+ $ this ->table ('email_queue ' )
35
+ ->changeColumn ('template ' , 'string ' , [
36
+ 'limit ' => 50 ,
37
+ ])
38
+ ->update ();
39
+ }
40
+ }
Original file line number Diff line number Diff line change 9
9
use Cake \ORM \Table ;
10
10
use EmailQueue \Database \Type \JsonType ;
11
11
use EmailQueue \Database \Type \SerializeType ;
12
+ use LengthException ;
12
13
13
14
/**
14
15
* EmailQueue Table.
15
16
*/
16
17
class EmailQueueTable extends Table
17
18
{
19
+ const MAX_TEMPLATE_LENGTH = 100 ;
20
+
18
21
/**
19
22
* {@inheritdoc}
20
23
*/
@@ -50,10 +53,15 @@ public function initialize(array $config = [])
50
53
* - config : the name of the email config to be used for sending
51
54
*
52
55
* @throws \Exception any exception raised in transactional callback
56
+ * @throws LengthException If `template` option length is greater than maximum allowed length
53
57
* @return bool
54
58
*/
55
59
public function enqueue ($ to , array $ data , array $ options = [])
56
60
{
61
+ if (strlen ($ options ['template ' ]) > self ::MAX_TEMPLATE_LENGTH ) {
62
+ throw new LengthException ('`template` length must be less or equal to ' . self ::MAX_TEMPLATE_LENGTH );
63
+ }
64
+
57
65
$ defaults = [
58
66
'subject ' => '' ,
59
67
'send_at ' => new FrozenTime ('now ' ),
You can’t perform that action at this time.
0 commit comments