From dea32345c8ef2fad80f3966a3047a10f42a39ba7 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 17 Oct 2015 20:54:40 -0400 Subject: [PATCH 1/3] Add failing test for #7570 Documented behavior that exists in 3.x is not working in 2.x --- .../Case/Controller/Component/FlashComponentTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php b/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php index 56905c545..64fe0ec7f 100644 --- a/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php @@ -158,6 +158,16 @@ class FlashComponentTest extends CakeTestCase { $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); + $this->Flash->alert('It worked', array('plugin' => 'MyPlugin')); + $expected = array( + 'message' => 'It worked', + 'key' => 'flash', + 'element' => 'MyPlugin.Flash/alert', + 'params' => array() + ); + $result = CakeSession::read('Message.flash'); + $this->assertEquals($expected, $result); + $this->Flash->error('It did not work', array('element' => 'error_thing')); $expected = array( 'message' => 'It did not work', From fd50d1976a4f083889f05e1616738510d7cbfe9e Mon Sep 17 00:00:00 2001 From: gmponos Date: Sat, 17 Oct 2015 15:56:01 +0300 Subject: [PATCH 2/3] Flash Component was not handling plugin option --- lib/Cake/Controller/Component/FlashComponent.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Component/FlashComponent.php b/lib/Cake/Controller/Component/FlashComponent.php index 2e0fa4e68..df89d34c3 100644 --- a/lib/Cake/Controller/Component/FlashComponent.php +++ b/lib/Cake/Controller/Component/FlashComponent.php @@ -38,6 +38,7 @@ class FlashComponent extends Component { 'key' => 'flash', 'element' => 'default', 'params' => array(), + 'plugin' => '', ); /** @@ -79,7 +80,11 @@ class FlashComponent extends Component { list($plugin, $element) = pluginSplit($options['element']); if ($plugin) { - $options['element'] = $plugin . '.Flash/' . $element; + $options['plugin'] = $plugin; + } + + if (!empty($options['plugin'])) { + $options['element'] = $options['plugin'] . '.Flash/' . $element; } else { $options['element'] = 'Flash/' . $element; } From 925647ae2b2a7713f030a6df16e61038e7769678 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 17 Oct 2015 20:59:02 -0400 Subject: [PATCH 3/3] Simplify code used to generate plugin flash messages. --- lib/Cake/Controller/Component/FlashComponent.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/Cake/Controller/Component/FlashComponent.php b/lib/Cake/Controller/Component/FlashComponent.php index df89d34c3..cab43f305 100644 --- a/lib/Cake/Controller/Component/FlashComponent.php +++ b/lib/Cake/Controller/Component/FlashComponent.php @@ -38,7 +38,6 @@ class FlashComponent extends Component { 'key' => 'flash', 'element' => 'default', 'params' => array(), - 'plugin' => '', ); /** @@ -77,17 +76,11 @@ class FlashComponent extends Component { $message = $message->getMessage(); } - list($plugin, $element) = pluginSplit($options['element']); - - if ($plugin) { - $options['plugin'] = $plugin; - } - + list($plugin, $element) = pluginSplit($options['element'], true); if (!empty($options['plugin'])) { - $options['element'] = $options['plugin'] . '.Flash/' . $element; - } else { - $options['element'] = 'Flash/' . $element; + $plugin = $options['plugin'] . '.'; } + $options['element'] = $plugin . 'Flash/' . $element; CakeSession::write('Message.' . $options['key'], array( 'message' => $message,