summaryrefslogtreecommitdiff
path: root/src/Renderer/RendererServiceProvider.php
blob: 2e41837bc6f7db50433c7ef58e293e2bef118cb5 (plain)
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
<?php

namespace Engelsystem\Renderer;

use Engelsystem\Container\ServiceProvider;

class RendererServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->registerRenderer();
        $this->registerHtmlEngine();
    }

    public function boot()
    {
        $renderer = $this->app->get('renderer');

        foreach ($this->app->tagged('renderer.engine') as $engine) {
            $renderer->addRenderer($engine);
        }
    }

    protected function registerRenderer()
    {
        $renderer = $this->app->make(Renderer::class);
        $this->app->instance(Renderer::class, $renderer);
        $this->app->instance('renderer', $renderer);
    }

    protected function registerHtmlEngine()
    {
        $htmlEngine = $this->app->make(HtmlEngine::class);
        $this->app->instance(HtmlEngine::class, $htmlEngine);
        $this->app->instance('renderer.htmlEngine', $htmlEngine);
        $this->app->tag('renderer.htmlEngine', ['renderer.engine']);
    }
}