diff options
author | Arnold Daniels <arnold@jasny.net> | 2016-11-17 16:17:55 +0100 |
---|---|---|
committer | Arnold Daniels <arnold@jasny.net> | 2016-11-17 16:17:55 +0100 |
commit | 7149ef62ca11d451dadd271f5cb63233a4ac0748 (patch) | |
tree | f141b8c05d75c5b86819edb63213ec8b93e281bd /src/Controller.php | |
parent | 14bc7de53fda2c44482c7cf46b896cfdd41aa68d (diff) | |
parent | b8540d92944123d15559f9033f523f9f6c5126ec (diff) | |
download | controller-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.php | 22 |
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() : ''; } } - |