mirror of
https://github.com/flextype/flextype.git
synced 2025-08-13 08:34:19 +02:00
Flextype Slim Integration - next round of integration
This commit is contained in:
@@ -73,7 +73,7 @@ class Cache
|
||||
$this->driver = $this->getCacheDriver();
|
||||
|
||||
// Set the cache namespace to our unique key
|
||||
$this->driver->setNamespace($this->$key);
|
||||
$this->driver->setNamespace($this->key);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -265,11 +265,11 @@ $flextype['view'] = function ($container) {
|
||||
// Add Entries Twig Extension
|
||||
$view->addExtension(new EntriesTwigExtension($container));
|
||||
|
||||
// Add Registry Twig Extension
|
||||
$view->addExtension(new RegistryTwigExtension());
|
||||
// Add Emitter Twig Extension
|
||||
$view->addExtension(new EmitterTwigExtension($container));
|
||||
|
||||
// Add Emitter Twig Extension
|
||||
$view->addExtension(new EmitterTwigExtension());
|
||||
$view->addExtension(new FlashTwigExtension($container));
|
||||
|
||||
return $view;
|
||||
};
|
||||
|
@@ -27,6 +27,6 @@ class EmitterTwigExtension extends \Twig_Extension
|
||||
|
||||
public function emit(string $event)
|
||||
{
|
||||
return $this->flextype['emitter']->emit($event);
|
||||
$this->flextype['emitter']->emit($event);
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,5 @@
|
||||
<?php
|
||||
/**
|
||||
* Slim Framework (http://slimframework.com)
|
||||
*
|
||||
* @link https://github.com/slimphp/Twig-View
|
||||
* @copyright Copyright (c) 2011-2015 Josh Lockhart
|
||||
* @license https://github.com/slimphp/Twig-View/blob/master/LICENSE.md (MIT License)
|
||||
*/
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
class EntriesTwigExtension extends \Twig_Extension
|
||||
|
49
flextype/twig/FlashTwigExtension.php
Normal file
49
flextype/twig/FlashTwigExtension.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
use Slim\Flash\Messages;
|
||||
|
||||
class FlashTwigExtension extends \Twig_Extension
|
||||
{
|
||||
|
||||
/**
|
||||
* Flextype Dependency Container
|
||||
*/
|
||||
private $flextype;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct($flextype)
|
||||
{
|
||||
$this->flextype = $flextype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for twig.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFunctions() : array
|
||||
{
|
||||
return [
|
||||
new \Twig_SimpleFunction('flash', [$this, 'getMessages']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Flash messages; If key is provided then returns messages
|
||||
* for that key.
|
||||
*
|
||||
* @param string $key
|
||||
* @return array
|
||||
*/
|
||||
public function getMessages($key = null) : array
|
||||
{
|
||||
if (null !== $key) {
|
||||
return $this->flextype['flash']->getMessage($key);
|
||||
}
|
||||
return $this->flextype['flash']->getMessages();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user