From ff88aff11a76192c6cd27a747a8e7012476fbbd2 Mon Sep 17 00:00:00 2001 From: "H. Watnou" Date: Wed, 9 Sep 2015 18:40:21 +0200 Subject: [PATCH 1/3] Cakephp 2.7's FlashComponent requires flash elements to be in subdir Elements/Flash. --- View/Elements/Flash/alert.ctp | 14 ++++++++++++++ View/Elements/alert.ctp | 15 +-------------- 2 files changed, 15 insertions(+), 14 deletions(-) create mode 100644 View/Elements/Flash/alert.ctp mode change 100644 => 120000 View/Elements/alert.ctp diff --git a/View/Elements/Flash/alert.ctp b/View/Elements/Flash/alert.ctp new file mode 100644 index 0000000..1830935 --- /dev/null +++ b/View/Elements/Flash/alert.ctp @@ -0,0 +1,14 @@ + +
+ + × + + +
\ No newline at end of file diff --git a/View/Elements/alert.ctp b/View/Elements/alert.ctp deleted file mode 100644 index 1830935..0000000 --- a/View/Elements/alert.ctp +++ /dev/null @@ -1,14 +0,0 @@ - -
- - × - - -
\ No newline at end of file diff --git a/View/Elements/alert.ctp b/View/Elements/alert.ctp new file mode 120000 index 0000000..b141ba6 --- /dev/null +++ b/View/Elements/alert.ctp @@ -0,0 +1 @@ +Flash/alert.ctp \ No newline at end of file From e52b4c20a94b80c4a7a8b8f20a3065fd340d7689 Mon Sep 17 00:00:00 2001 From: Kim Vahl Date: Tue, 26 Apr 2016 15:48:01 +0200 Subject: [PATCH 2/3] Allow use of the class parameter. --- View/Elements/Flash/alert.ctp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/View/Elements/Flash/alert.ctp b/View/Elements/Flash/alert.ctp index 1830935..af009a6 100644 --- a/View/Elements/Flash/alert.ctp +++ b/View/Elements/Flash/alert.ctp @@ -1,4 +1,7 @@ Date: Tue, 26 Apr 2016 15:52:46 +0200 Subject: [PATCH 3/3] Use FlashComponent::alert() in examples. Use FlashComponent::alert() in examples as SessionComponent::setFlash() is deprecated since cakephp 2.7 and the SessionComponent does not exist since cakephp 3.0.0. --- Controller/BoostCakeController.php | 20 ++++++++++---------- View/Elements/bootstrap2/alerts.ctp | 8 ++++---- View/Elements/bootstrap3/alerts.ctp | 12 ++++++------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Controller/BoostCakeController.php b/Controller/BoostCakeController.php index ea09f06..0513481 100644 --- a/Controller/BoostCakeController.php +++ b/Controller/BoostCakeController.php @@ -40,14 +40,14 @@ public function index() { * @return void */ public function bootstrap2() { - $this->Session->setFlash(__('Alert notice message testing...'), 'alert', array( + $this->Flash->alert(__('Alert notice message testing...'), 'alert', array( 'plugin' => 'BoostCake', ), 'notice'); - $this->Session->setFlash(__('Alert success message testing...'), 'alert', array( + $this->Flash->alert(__('Alert success message testing...'), 'alert', array( 'plugin' => 'BoostCake', - 'class' => 'alert-success' + 'params' => ['class' => 'alert-success'] ), 'success'); - $this->Session->setFlash(__('Alert error message testing...'), 'alert', array( + $this->Flash->alert(__('Alert error message testing...'), 'alert', array( 'plugin' => 'BoostCake', 'class' => 'alert-error' ), 'error'); @@ -59,19 +59,19 @@ public function bootstrap2() { * @return void */ public function bootstrap3() { - $this->Session->setFlash(__('Alert success message testing...'), 'alert', array( + $this->Flash->alert(__('Alert success message testing...'), 'alert', array( 'plugin' => 'BoostCake', - 'class' => 'alert-success' + 'params' => ['class' => 'alert-success'] ), 'success'); - $this->Session->setFlash(__('Alert info message testing...'), 'alert', array( + $this->Flash->alert(__('Alert info message testing...'), 'alert', array( 'plugin' => 'BoostCake', 'class' => 'alert-info' ), 'info'); - $this->Session->setFlash(__('Alert warning message testing...'), 'alert', array( + $this->Flash->alert(__('Alert warning message testing...'), 'alert', array( 'plugin' => 'BoostCake', - 'class' => 'alert-warning' + 'params' => ['class' => 'alert-danger'], ), 'warning'); - $this->Session->setFlash(__('Alert danger message testing...'), 'alert', array( + $this->Flash->alert(__('Alert danger message testing...'), 'alert', array( 'plugin' => 'BoostCake', 'class' => 'alert-danger' ), 'danger'); diff --git a/View/Elements/bootstrap2/alerts.ctp b/View/Elements/bootstrap2/alerts.ctp index b814980..ba3bd9a 100644 --- a/View/Elements/bootstrap2/alerts.ctp +++ b/View/Elements/bootstrap2/alerts.ctp @@ -3,16 +3,16 @@ echo $this->Session->flash(); // Controller -$this->Session->setFlash(__('Alert notice message testing...'), 'alert', array( +$this->Flash->alert(__('Alert notice message testing...'), 'alert', array( 'plugin' => 'BoostCake', )); -$this->Session->setFlash(__('Alert success message testing...'), 'alert', array( +$this->Flash->alert(__('Alert success message testing...'), 'alert', array( 'plugin' => 'BoostCake', - 'class' => 'alert-success' + 'params' => ['class' => 'alert-success'] )); -$this->Session->setFlash(__('Alert error message testing...'), 'alert', array( +$this->Flash->alert(__('Alert error message testing...'), 'alert', array( 'plugin' => 'BoostCake', 'class' => 'alert-error' )); diff --git a/View/Elements/bootstrap3/alerts.ctp b/View/Elements/bootstrap3/alerts.ctp index 247145c..ac7d9c0 100644 --- a/View/Elements/bootstrap3/alerts.ctp +++ b/View/Elements/bootstrap3/alerts.ctp @@ -3,22 +3,22 @@ echo $this->Session->flash(); // Controller -$this->Session->setFlash(__('Alert success message testing...'), 'alert', array( +$this->Flash->alert(__('Alert success message testing...'), 'alert', array( 'plugin' => 'BoostCake', - 'class' => 'alert-success' + 'params' => ['class' => 'alert-success'] )); -$this->Session->setFlash(__('Alert info message testing...'), 'alert', array( +$this->Flash->alert(__('Alert info message testing...'), 'alert', array( 'plugin' => 'BoostCake', 'class' => 'alert-info' )); -$this->Session->setFlash(__('Alert warning message testing...'), 'alert', array( +$this->Flash->alert(__('Alert warning message testing...'), 'alert', array( 'plugin' => 'BoostCake', - 'class' => 'alert-warning' + 'params' => ['class' => 'alert-danger'], )); -$this->Session->setFlash(__('Alert danger message testing...'), 'alert', array( +$this->Flash->alert(__('Alert danger message testing...'), 'alert', array( 'plugin' => 'BoostCake', 'class' => 'alert-danger' ));