File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44root = true
55
66[* ]
7- indent_style = tab
7+ indent_style = space
88indent_size = 4
99charset = " utf-8"
1010end_of_line = lf
Original file line number Diff line number Diff line change 11language : php
22
33php :
4- - 5.3
54 - 5.4
65 - 5.5
76 - 5.6
87
98env :
10- global :
11- - PLUGIN_NAME=InlineCss
12- - REQUIRE=""
13- - DB=mysql CAKE_VERSION=2.4
14-
159 matrix :
16- - DB=mysql CAKE_VERSION=2.4
17- - DB=mysql CAKE_VERSION=2.5
18- - DB=mysql CAKE_VERSION=2.6
10+ - DB=mysql db_class='Cake\Database\Driver\Mysql' db_dsn='mysql:host=0.0.0.0;dbname=cakephp_test' db_database='cakephp_test' db_username='travis' db_password=''
11+ global :
12+ - DEFAULT=1
1913
2014matrix :
15+ fast_finish : true
16+
2117 include :
2218 - php : 5.4
23- env :
24- - PHPCS=1
19+ env : PHPCS=1 DEFAULT=0
20+
21+ - php : 5.5
22+ env : COVERALLS=1 DEFAULT=0
23+
2524 allow_failures :
2625 - php : 5.4
27- env :
28- - PHPCS=1
26+ env : PHPCS=1 DEFAULT=0
2927
3028before_script :
31- - git clone https://github.com/FriendsOfCake/travis.git --depth 1 ../travis
32- - ../travis/before_script.sh
33- - echo "require APP . 'vendor' . DS . 'autoload.php';" >> ../cakephp/app/Config/bootstrap.php
29+ - composer self-update
30+ - composer install --prefer-source --no-interaction --dev
3431
35- script :
36- - ../travis/script.sh
32+ - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi"
33+
34+ - sh -c "if [ '$PHPCS' = '1' ]; then composer require --dev cakephp/cakephp-codesniffer=2.*; fi"
35+
36+ - sh -c "if [ '$COVERALLS' = '1' ]; then composer require --dev satooshi/php-coveralls:dev-master; fi"
37+ - sh -c "if [ '$COVERALLS' = '1' ]; then mkdir -p build/logs; fi"
3738
38- after_success :
39- - ../travis/after_success.sh
39+ - phpenv rehash
40+ - set +H
41+ - cp phpunit.xml.dist phpunit.xml
42+
43+ script :
44+ - sh -c "if [ '$COVERALLS' = '1' ]; then phpunit --coverage-clover build/logs/clover.xml; fi"
45+ - sh -c "if [ '$COVERALLS' = '1' ]; then php vendor/bin/coveralls -c .coveralls.yml -v; fi"
46+ - sh -c "if [ '$DEFAULT' = '1' ]; then phpunit; fi"
47+ - sh -c "if [ '$PHPCS' = '1' ]; then vendor/bin/phpcs -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP --ignore=tests src/ ; fi"
4048
4149notifications :
4250 email : false
Load diff This file was deleted.
Load diff This file was deleted.
Load diff This file was deleted.
Original file line number Diff line number Diff line change 1212 }
1313 ],
1414 "require" : {
15+ "cakephp/cakephp" : " ~3.0" ,
1516 "tijsverkoyen/css-to-inline-styles" : " ^1.5"
1617 },
17- "extra" : {
18- "installer-name" : " InlineCss"
18+ "autoload" : {
19+ "psr-4" : {
20+ "InlineCss\\ " : " src"
21+ }
22+ },
23+ "autoload-dev" : {
24+ "psr-4" : {
25+ "Cake\\ Test\\ " : " ./vendor/cakephp/cakephp/tests" ,
26+ "InlineCss\\ Test\\ " : " tests"
27+ }
1928 }
2029}
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <phpunit
3+ colors =" true"
4+ processIsolation =" false"
5+ stopOnFailure =" false"
6+ syntaxCheck =" false"
7+ bootstrap =" ./tests/bootstrap.php"
8+ >
9+ <php >
10+ <ini name =" memory_limit" value =" -1" />
11+ <ini name =" apc.enable_cli" value =" 1" />
12+ </php >
13+
14+ <!-- Add any additional test suites you want to run here -->
15+ <testsuites >
16+ <testsuite name =" App Test Suite" >
17+ <directory >./tests/TestCase</directory >
18+ </testsuite >
19+ <!-- Add plugin test suites here. -->
20+ </testsuites >
21+
22+ <!-- Setup a listener for fixtures -->
23+ <listeners >
24+ <listener
25+ class =" \Cake\TestSuite\Fixture\FixtureInjector"
26+ file =" ./vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php" >
27+ <arguments >
28+ <object class =" \Cake\TestSuite\Fixture\FixtureManager" />
29+ </arguments >
30+ </listener >
31+ </listeners >
32+
33+ <filter >
34+ <blacklist >
35+ <directory suffix =" .php" >./vendor/</directory >
36+ <directory suffix =" .ctp" >./vendor/</directory >
37+
38+ <directory suffix =" .php" >./tests/</directory >
39+ <directory suffix =" .ctp" >./tests/</directory >
40+ </blacklist >
41+ </filter >
42+
43+ </phpunit >
Original file line number Diff line number Diff line change @@ -6,31 +6,31 @@ This plugin provides a CakePHP helper that uses [CssToInlineStyles](https://gith
66
77## Requirements
88
9- * CakePHP 2 .x
9+ * CakePHP 3 .x
1010
1111## Installation
1212
1313This plugin should be installed using Composer:-
1414
1515```
16- composer require drmonkeyninja/cakephp-inline-css:2 .0.*
16+ composer require drmonkeyninja/cakephp-inline-css:3 .0.*
1717```
1818
1919Then add the following line to your bootstrap.php to load the plugin.
2020
2121``` php
22- CakePlugin ::load('InlineCss. InlineCss');
22+ Plugin ::load('InlineCss');
2323```
2424
2525## Usage
2626
2727To use this plugin you want to load the ` InlineCss ` helper to use with your email's HTML template:-
2828
2929``` php
30- $Email = new CakeEmail ();
31- $Email ->template('welcome', 'fancy')
30+ $email = new Email ();
31+ $email ->template('welcome', 'fancy')
3232 ->emailFormat('html')
33- ->helpers(array( 'InlineCss.InlineCss') )
33+ ->helpers([ 'InlineCss.InlineCss'] )
3434 ->to('bob@example.com')
3535 ->from('app@domain.com')
3636 ->send();
@@ -53,4 +53,4 @@ It will be rendered as:-
5353
5454This makes generating HTML emails a lot simpler as you can write your CSS in a more DRY approach.
5555
56- I recommend you look consider deferring the sending of emails using something like the excellent [ Queue plugin] ( https://github.com/dereuromark/cakephp-queue/tree/2.x ) to improve your app's response time for users when using this plugin.
56+ I recommend you look consider deferring the sending of emails using something like the excellent [ Queue plugin] ( https://github.com/dereuromark/cakephp-queue ) to improve your app's response time for users when using this plugin.
Original file line number Diff line number Diff line change 1+ <?php
2+ namespace InlineCss \View \Helper ;
3+
4+ use Cake \View \Helper ;
5+ use TijsVerkoyen \CssToInlineStyles \CssToInlineStyles ;
6+
7+ class InlineCssHelper extends Helper
8+ {
9+
10+ /**
11+ * After layout logic.
12+ *
13+ * @param \Cake\Event\Event $event Event
14+ * @param string $layoutFile Layout filename
15+ */
16+ public function afterLayout (\Cake \Event \Event $ event , $ layoutFile )
17+ {
18+ $ content = $ this ->_View ->Blocks ->get ('content ' );
19+
20+ if (!isset ($ this ->InlineCss )) {
21+ $ this ->InlineCss = new CssToInlineStyles ();
22+ }
23+
24+ // Convert inline style blocks to inline CSS on the HTML content.
25+ $ this ->InlineCss ->setHTML ($ content );
26+ $ this ->InlineCss ->setUseInlineStylesBlock (true );
27+ $ content = $ this ->InlineCss ->convert ();
28+
29+ $ this ->_View ->Blocks ->set ('content ' , $ content );
30+
31+ return ;
32+ }
33+
34+ }
Original file line number Diff line number Diff line change 1+ <?php
2+ namespace InlineCss \TestCase \View \Helper ;
3+
4+ use Cake \Network \Request ;
5+ use Cake \TestSuite \TestCase ;
6+ use Cake \View \View ;
7+ use InlineCss \View \Helper \InlineCssHelper ;
8+
9+ class InlineCssHelperTest extends TestCase
10+ {
11+
12+ public $ InlineCss = null ;
13+
14+ public function setUp ()
15+ {
16+ parent ::setUp ();
17+
18+ $ this ->View = new View (new Request ());
19+ $ this ->InlineCss = new InlineCssHelper ($ this ->View );
20+ }
21+
22+ public function testAfterLayout ()
23+ {
24+ $ this ->View ->Blocks ->set ('content ' , '<style type="text/css">a{color:red}</style><p><a href="#">Test</a></p> ' );
25+
26+ $ this ->InlineCss ->afterLayout (new \Cake \Event \Event ('' ), null );
27+
28+ $ expected = '<p><a href="#" style="color: red;">Test</a></p> ' ;
29+ $ this ->assertContains ($ expected , $ this ->View ->Blocks ->get ('content ' ));
30+ }
31+
32+ }
You can’t perform that action at this time.
0 commit comments