Added message service into core Grav

This commit is contained in:
Andy Miller
2016-11-09 10:48:36 -07:00
parent 079468c609
commit 95ab80b8f9
3 changed files with 32 additions and 0 deletions

View File

@@ -6,6 +6,7 @@
* Added Base32 encode/decode class
* Added a new `User::find()` method
1. [](#improved)
* Moved `messages` object into core Grav from login plugin
* Added `getTaxonomyItemKeys` to the Taxonomy object [#1124](https://github.com/getgrav/grav/issues/1124)
* Added a `redirect_me` Twig function [#1124](https://github.com/getgrav/grav/issues/1124)
* Added a Caddyfile for newer Caddy versions [#1115](https://github.com/getgrav/grav/issues/1115)

View File

@@ -29,6 +29,7 @@ class Grav extends Container
'events' => 'RocketTheme\Toolbox\Event\EventDispatcher',
'cache' => 'Grav\Common\Cache',
'session' => 'Grav\Common\Session',
'Grav\Common\Service\MessagesServiceProvider',
'plugins' => 'Grav\Common\Plugins',
'themes' => 'Grav\Common\Themes',
'twig' => 'Grav\Common\Twig\Twig',

View File

@@ -0,0 +1,30 @@
<?php
/**
* @package Grav.Common.Service
*
* @copyright Copyright (C) 2014 - 2016 RocketTheme, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Common\Service;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use RocketTheme\Toolbox\Session\Message;
class MessagesServiceProvider implements ServiceProviderInterface
{
public function register(Container $container)
{
// Define session message service.
$container['messages'] = function ($c) {
$session = $c['session'];
if (!isset($session->messages)) {
$session->messages = new Message;
}
return $session->messages;
};
}
}