Skip to content

Commit 23b3a65

Browse files
authored
Merge pull request #5 from tattersoftware/qol
Quality of Life Changes
2 parents 22278e4 + 72c35b5 commit 23b3a65

File tree

6 files changed

+54
-22
lines changed

6 files changed

+54
-22
lines changed

composer.json

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "tatter/outbox",
3+
"type": "library",
34
"description": "Email toolkit for CodeIgniter 4",
45
"keywords": [
56
"codeigniter",
@@ -19,30 +20,17 @@
1920
"role": "Developer"
2021
}
2122
],
22-
"repositories": [
23-
{
24-
"type": "vcs",
25-
"url": "https://github.com/codeigniter4/CodeIgniter4"
26-
}
27-
],
28-
"minimum-stability": "dev",
29-
"prefer-stable": true,
3023
"require": {
31-
"php" : ">=7.2",
24+
"php": ">=7.2",
25+
"components/jquery": "^3.3",
3226
"tatter/assets": "^2.2",
3327
"tijsverkoyen/css-to-inline-styles": "^2.2",
34-
"twbs/bootstrap": "^4.5",
35-
"components/jquery": "^3.3"
28+
"twbs/bootstrap": "^4.5"
3629
},
3730
"require-dev": {
3831
"codeigniter4/codeigniter4": "dev-develop",
39-
"codeigniter4/codeigniter4-standard": "^1.0",
40-
"fzaninotto/faker": "^1.9@dev",
41-
"mikey179/vfsstream": "^1.6",
4232
"myth/auth": "dev-develop",
43-
"phpstan/phpstan": "^0.12",
44-
"phpunit/phpunit": "^8.5",
45-
"squizlabs/php_codesniffer": "^3.5"
33+
"tatter/tools": "^1.0"
4634
},
4735
"autoload": {
4836
"psr-4": {
@@ -54,9 +42,17 @@
5442
"Tests\\Support\\": "tests/_support"
5543
}
5644
},
45+
"repositories": [
46+
{
47+
"type": "vcs",
48+
"url": "https://github.com/codeigniter4/CodeIgniter4"
49+
}
50+
],
51+
"minimum-stability": "dev",
52+
"prefer-stable": true,
5753
"scripts": {
5854
"analyze": "phpstan analyze",
59-
"style": "phpcbf --standard=./vendor/codeigniter4/codeigniter4-standard/CodeIgniter4 src/ tests/",
55+
"style": "phpcs --standard=./vendor/codeigniter4/codeigniter4-standard/CodeIgniter4 tests/ src/",
6056
"test": "phpunit"
6157
}
6258
}

examples/Outbox.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,26 @@ class Outbox extends \Tatter\Outbox\Config\Outbox
1919
*/
2020
public $logging = true;
2121

22+
/**
23+
* Whether to include routes to the Templates Controller.
24+
*
25+
* @var boolean
26+
*/
27+
public $routeTemplates = false;
28+
29+
/**
30+
* Layout to use for template management.
31+
*
32+
* @var string
33+
*/
34+
public $layout = 'Tatter\Outbox\Views\layout';
35+
2236
/**
2337
* Default view for email templating.
2438
*
2539
* @var string
2640
*/
27-
public $template = 'Tatter\Outbox\Views\layout';
41+
public $template = 'Tatter\Outbox\Views\template';
2842

2943
/**
3044
* Default CSS style view to apply to the template.

src/Config/Outbox.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ class Outbox extends BaseConfig
1111
*/
1212
public $logging = true;
1313

14+
/**
15+
* Whether to include routes to the Templates Controller.
16+
*
17+
* @var boolean
18+
*/
19+
public $routeTemplates = false;
20+
1421
/**
1522
* Layout to use for template management.
1623
*

src/Config/Routes.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
if (empty(config('Outbox')->routeTemplates))
4+
{
5+
return;
6+
}
7+
8+
// Routes to Email Templates
9+
$routes->group('emails', ['namespace' => '\Tatter\Outbox\Controllers'], function ($routes)
10+
{
11+
$routes->get('templates/new/(:segment)', 'Templates::new/$1');
12+
$routes->get('templates/send/(:segment)', 'Templates::send/$1');
13+
$routes->post('templates/send/(:segment)', 'Templates::send_commit/$1');
14+
$routes->presenter('templates', ['controller' => 'Templates']);
15+
});

src/Entities/Template.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function render($data = [], string $styles = null): string
2929
}
3030

3131
// Replace tokens with $data values
32-
$body = service('parser')->setData($data, 'raw')->renderString($this->attributes['body']);
32+
$body = service('parser')->setData($data, 'raw')->renderString($this->attributes['body'], ['debug' => false]);
3333

3434
// If this has a parent Template then render it with this body
3535
if ($parent = $this->getParent())

src/Outbox.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static function fromTemplate(Template $template, $data = [], string $styl
2626
$email->wordWrap = false;
2727

2828
// Replace tokens with $data values
29-
$email->setSubject(service('parser')->setData($data)->renderString($template->subject));
29+
$email->setSubject(service('parser')->setData($data)->renderString($template->subject, ['debug' => false]));
3030
$email->setMessage($template->render($data, $styles));
3131

3232
return $email;
@@ -53,7 +53,7 @@ public static function inline(array $data, string $template = null, string $styl
5353
$styles = config('Outbox')->styles;
5454
}
5555

56-
return (new CssToInlineStyles)->convert(view($template, $data), view($styles));
56+
return (new CssToInlineStyles)->convert(view($template, $data, ['debug' => false]), view($styles, [], ['debug' => false]));
5757
}
5858

5959
/**

0 commit comments

Comments
 (0)