summaryrefslogtreecommitdiffstats
path: root/src/Controller.php
diff options
context:
space:
mode:
authorArnold Daniels <arnold@jasny.net>2016-11-17 16:17:55 +0100
committerArnold Daniels <arnold@jasny.net>2016-11-17 16:17:55 +0100
commit7149ef62ca11d451dadd271f5cb63233a4ac0748 (patch)
treef141b8c05d75c5b86819edb63213ec8b93e281bd /src/Controller.php
parent14bc7de53fda2c44482c7cf46b896cfdd41aa68d (diff)
parentb8540d92944123d15559f9033f523f9f6c5126ec (diff)
downloadcontroller-7149ef62ca11d451dadd271f5cb63233a4ac0748.zip
controller-7149ef62ca11d451dadd271f5cb63233a4ac0748.tar.gz
controller-7149ef62ca11d451dadd271f5cb63233a4ac0748.tar.bz2
Merge branch 'Flash' of https://github.com/Minstel/controller into Minstel-Flash
Diffstat (limited to 'src/Controller.php')
-rw-r--r--src/Controller.php22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/Controller.php b/src/Controller.php
index 057653e..9f69160 100644
--- a/src/Controller.php
+++ b/src/Controller.php
@@ -41,6 +41,12 @@ abstract class Controller
'application/x-www-form-urlencoded' => 'post',
'multipart/form-data' => 'post'
];
+
+ /**
+ * Flash
+ * @var Flash
+ */
+ protected $flash = null;
/**
* Run the controller
@@ -282,6 +288,21 @@ abstract class Controller
return $errorResponse;
}
+
+ /**
+ * Set the flash message and/or return the flash object.
+ *
+ * @param mixed $type flash type, eg. 'error', 'notice' or 'success'
+ * @param mixed $message flash message
+ * @return Flash
+ */
+ public function flash($type = null, $message = null)
+ {
+ if (!isset($this->flash)) $this->flash = new Flash();
+ if ($type && $message) $this->flash->set($type, $message);
+
+ return $this->flash;
+ }
/**
* Check if response is 2xx succesful, or empty
@@ -516,4 +537,3 @@ abstract class Controller
return $request ? $request->getMethod() : '';
}
}
-