Skip to content

Commit

Permalink
Merge branch 'release/2.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkyle committed Dec 22, 2016
2 parents 01095c3 + 4f2b5f8 commit 52433d6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -23,7 +23,7 @@
},

"require": {
"germania-kg/websites": "^1.0",
"germania-kg/websites": "^2.0",
"psr/log": "^1.0",
"slim/slim": "^3.5",
"psr/http-message": "^1.0",
Expand Down
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 18 additions & 8 deletions src/WebsiteMiddleware.php
Expand Up @@ -87,27 +87,37 @@ public function __invoke(Request $request, Response $response, $next)


// ---------------------------------------
// 3. After that, render 'full page' template
// 3. Create template variables
// ---------------------------------------

// Output global website template
$this->logger->debug("Render page template…");

$render = $this->render;
$full_page_html = $render( $this->template, array_merge(
$vars = array_merge(
$this->defaults, [
'title' => $website->getTitle(),
'id' => $website->getDomId(),
'base_url' => $request->getUri()->getBaseUrl(),
'content' => (string) $content_response->getBody()
]
));
);

$vars['javascripts'] = isset($vars['javascripts']) ? array_merge($vars['javascripts'], $website->getJavascripts()) : $website->getJavascripts();
$vars['stylesheets'] = isset($vars['stylesheets']) ? array_merge($vars['stylesheets'], $website->getStylesheets()) : $website->getStylesheets();


// ---------------------------------------
// 5. After that, render 'full page' template
// ---------------------------------------

// Output global website template
$this->logger->debug("Render page template…");

$render = $this->render;
$full_page_html = $render( $this->template, $vars);

$this->logger->debug("Finish page template render; write response");


// ---------------------------------------
// 4. Write response
// 6. Write response
// ---------------------------------------

$full_html_response_body = new ResponseBody(fopen('php://temp', 'r+'));
Expand Down
4 changes: 4 additions & 0 deletions tests/default/WebsiteMiddlewareTest.php
Expand Up @@ -22,6 +22,8 @@ public function testInstantiation( $template, $defaults, $logger )
$website_mock = $this->prophesize( WebsiteInterface::class );
$website_mock->getTitle()->willReturn( "TheTitle" );
$website_mock->getDomId()->willReturn( "dom-id" );
$website_mock->getJavascripts()->willReturn( array("javascript") );
$website_mock->getStylesheets()->willReturn( array("stylesheet") );
$website = $website_mock->reveal();


Expand Down Expand Up @@ -50,6 +52,8 @@ public function testInvokation( $template, $defaults, $logger )
$website_mock = $this->prophesize( WebsiteInterface::class );
$website_mock->getTitle()->willReturn( "TheTitle" );
$website_mock->getDomId()->willReturn( "dom-id" );
$website_mock->getJavascripts()->willReturn( array("javascript") );
$website_mock->getStylesheets()->willReturn( array("stylesheet") );
$website = $website_mock->reveal();

$container_mock = $this->prophesize( ContainerInterface::class );
Expand Down

0 comments on commit 52433d6

Please sign in to comment.