Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Console updates

- Simplified and clarified interaction between index.php and bootstrap.php
- Added ViewPhpRenderer service based off of HTTP view manager implementation
  for use with console. This may need to move to PhlyBlog.
  • Loading branch information...
commit 9d782419636fac4108a3012f5e2c409af363a806 1 parent 61727a3
@weierophinney authored
View
1  bootstrap.php
@@ -15,3 +15,4 @@
// Bootstrap application
$application = Zend\Mvc\Application::init(include 'config/application.config.php');
+return $application;
View
32 module/Application/Module.php
@@ -11,6 +11,7 @@
use Zend\Mvc\View\Http\ViewManager;
use Zend\Stdlib\ArrayUtils;
use Zend\View\Model;
+use Zend\View\Renderer\PhpRenderer;
class Module
{
@@ -55,8 +56,29 @@ public function getServiceConfig()
$router = TreeRouteStack::factory($routerConfig);
return $router;
},
- 'viewmanager' => function ($services) {
- return new ViewManager();
+ 'viewphprenderer' => function ($services) {
+ $helpers = $services->get('ViewHelperManager');
+ $resolver = $services->get('ViewResolver');
+
+ $renderer = new PhpRenderer();
+ $renderer->setHelperPluginManager($helpers);
+ $renderer->setResolver($resolver);
+
+ $config = $services->get('Config');
+ if ($services->has('MvcEvent')) {
+ $event = $services->get('MvcEvent');
+ $model = $event->getViewModel();
+ } else {
+ $model = new Model\ViewModel();
+ }
+ $layout = 'layout/layout';
+ if (isset($config['view_manager']['layout'])) {
+ $layout = $config['view_manager']['layout'];
+ }
+ $model->setTemplate($layout);
+ $helpers->plugin('view_model')->setRoot($model);
+
+ return $renderer;
},
));
}
@@ -79,6 +101,7 @@ public function onBootstrap($e)
$services = $app->getServiceManager();
$events = $app->getEventManager();
$this->config = $services->get('config');
+ $services->setService('MvcEvent', $e);
$this->initAcls($e);
$this->initView($e);
@@ -96,6 +119,9 @@ public function initView($e)
{
$app = $e->getApplication();
$services = $app->getServiceManager();
+ if (!$services->has('ViewRenderer')) {
+ return;
+ }
$config = $this->config;
$view = $services->get('ViewRenderer');
@@ -119,7 +145,7 @@ public function initView($e)
public static function prepareCompilerView($view, $config, $services)
{
- $renderer = $services->get('ViewRenderer');
+ $renderer = $services->get('ViewPhpRenderer');
$view->addRenderingStrategy(function($e) use ($renderer) {
return $renderer;
}, 100);
View
2  public/index.php
@@ -1,3 +1,3 @@
<?php
-require __DIR__ . '/../bootstrap.php';
+$application = include __DIR__ . '/../bootstrap.php';
$application->run()->send();
Please sign in to comment.
Something went wrong with that request. Please try again.