From 291fa69c2bf1616632c751969c5627a27db13e41 Mon Sep 17 00:00:00 2001 From: Milos Stojanovic Date: Sun, 16 Jun 2019 11:54:58 +0200 Subject: [PATCH] config add to head/body --- backend/Services/View/Adapters/Vuejs.php | 5 +++++ configuration_sample.php | 4 ++++ tests/backend/Unit/MainTest.php | 20 -------------------- tests/backend/configuration.php | 4 ++++ 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/backend/Services/View/Adapters/Vuejs.php b/backend/Services/View/Adapters/Vuejs.php index 3757c5b..c3e1f44 100644 --- a/backend/Services/View/Adapters/Vuejs.php +++ b/backend/Services/View/Adapters/Vuejs.php @@ -25,6 +25,8 @@ class Vuejs implements Service, ViewInterface public function init(array $config = []) { + $this->add_to_head = isset($config['add_to_head']) ? $config['add_to_head'] : ''; + $this->add_to_body = isset($config['add_to_body']) ? $config['add_to_body'] : ''; } public function getIndexPage() @@ -41,6 +43,7 @@ class Vuejs implements Service, ViewInterface '.$title.' + '.$this->add_to_head.' @@ -50,6 +53,8 @@ class Vuejs implements Service, ViewInterface
+ + '.$this->add_to_body.' '; diff --git a/configuration_sample.php b/configuration_sample.php index 473f93d..23c22d4 100644 --- a/configuration_sample.php +++ b/configuration_sample.php @@ -75,6 +75,10 @@ return [ ], 'Filegator\Services\View\ViewInterface' => [ 'handler' => '\Filegator\Services\View\Adapters\Vuejs', + 'config' => [ + 'add_to_head' => '', + 'add_to_body' => '', + ], ], 'Filegator\Services\Storage\Filesystem' => [ 'handler' => '\Filegator\Services\Storage\Filesystem', diff --git a/tests/backend/Unit/MainTest.php b/tests/backend/Unit/MainTest.php index a8b853b..95ef07d 100644 --- a/tests/backend/Unit/MainTest.php +++ b/tests/backend/Unit/MainTest.php @@ -15,7 +15,6 @@ use Filegator\Config\Config; use Filegator\Container\Container; use Filegator\Kernel\Request; use Filegator\Kernel\Response; -use Filegator\Services\View\Adapters\Vuejs; use Tests\FakeResponse; use Tests\FakeStreamedResponse; use Tests\TestCase; @@ -39,23 +38,4 @@ class MainTest extends TestCase $this->assertEquals($app->resolve(Request::class), $request); $this->assertInstanceOf(Response::class, $app->resolve(Response::class)); } - - public function testServices() - { - $config = [ - 'services' => [ - 'Service1' => [ - 'handler' => 'Filegator\Services\View\Adapters\Vuejs', - ], - 'Service2' => [ - 'handler' => 'Filegator\Services\View\Adapters\Vuejs', - ], - ], - ]; - - $app = new App(new Config($config), new Request(), new FakeResponse(), new FakeStreamedResponse(), new Container()); - - $this->assertEquals($app->resolve('Service1'), new Vuejs(new Config($config))); - $this->assertEquals($app->resolve('Service2'), new Vuejs(new Config($config))); - } } diff --git a/tests/backend/configuration.php b/tests/backend/configuration.php index c490062..803fb3c 100644 --- a/tests/backend/configuration.php +++ b/tests/backend/configuration.php @@ -46,6 +46,10 @@ return [ ], 'Filegator\Services\View\ViewInterface' => [ 'handler' => '\Filegator\Services\View\Adapters\Vuejs', + 'config' => [ + 'add_to_head' => '', + 'add_to_body' => '', + ], ], 'Filegator\Services\Storage\Filesystem' => [ 'handler' => '\Filegator\Services\Storage\Filesystem',