-
Notifications
You must be signed in to change notification settings - Fork 0
/
ViewServiceProvider.php
61 lines (50 loc) · 1.37 KB
/
ViewServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* PhalconSlayer\Framework.
*
* @copyright 2015-2016 Daison Carino <daison12006013@gmail.com>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://docs.phalconslayer.com
*/
/**
*/
namespace Clarity\View;
use Phalcon\Events\Event;
use Phalcon\Events\Manager;
use Phalcon\Mvc\View\Engine\Php;
use Clarity\View\Volt\VoltAdapter;
use Clarity\View\Blade\BladeAdapter;
use Clarity\Support\Phalcon\Mvc\View;
use Clarity\Providers\ServiceProvider;
class ViewServiceProvider extends ServiceProvider
{
protected $alias = 'view';
protected $shared = true;
public function boot()
{
$event_manager = new Manager;
$event_manager->attach('view:afterRender',
function (
Event $event,
View $dispatcher,
$exception
) {
$flash = $dispatcher->getDI()->get('flash');
$flash->destroy();
}
);
di()->get('view')->setEventsManager($event_manager);
return $this;
}
public function register()
{
$view = new View;
$view->setViewsDir(config()->path->views);
$view->registerEngines([
'.phtml' => Php::class,
'.volt' => VoltAdapter::class,
'.blade.php' => BladeAdapter::class,
]);
return $view;
}
}