Skip to content

Commit

Permalink
Console updates
Browse files Browse the repository at this point in the history
- 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
weierophinney committed Sep 25, 2012
1 parent 61727a3 commit 9d78241
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions bootstrap.php
Expand Up @@ -15,3 +15,4 @@


// Bootstrap application // Bootstrap application
$application = Zend\Mvc\Application::init(include 'config/application.config.php'); $application = Zend\Mvc\Application::init(include 'config/application.config.php');
return $application;
32 changes: 29 additions & 3 deletions module/Application/Module.php
Expand Up @@ -11,6 +11,7 @@
use Zend\Mvc\View\Http\ViewManager; use Zend\Mvc\View\Http\ViewManager;
use Zend\Stdlib\ArrayUtils; use Zend\Stdlib\ArrayUtils;
use Zend\View\Model; use Zend\View\Model;
use Zend\View\Renderer\PhpRenderer;


class Module class Module
{ {
Expand Down Expand Up @@ -55,8 +56,29 @@ public function getServiceConfig()
$router = TreeRouteStack::factory($routerConfig); $router = TreeRouteStack::factory($routerConfig);
return $router; return $router;
}, },
'viewmanager' => function ($services) { 'viewphprenderer' => function ($services) {
return new ViewManager(); $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;
}, },
)); ));
} }
Expand All @@ -79,6 +101,7 @@ public function onBootstrap($e)
$services = $app->getServiceManager(); $services = $app->getServiceManager();
$events = $app->getEventManager(); $events = $app->getEventManager();
$this->config = $services->get('config'); $this->config = $services->get('config');
$services->setService('MvcEvent', $e);
$this->initAcls($e); $this->initAcls($e);
$this->initView($e); $this->initView($e);


Expand All @@ -96,6 +119,9 @@ public function initView($e)
{ {
$app = $e->getApplication(); $app = $e->getApplication();
$services = $app->getServiceManager(); $services = $app->getServiceManager();
if (!$services->has('ViewRenderer')) {
return;
}
$config = $this->config; $config = $this->config;
$view = $services->get('ViewRenderer'); $view = $services->get('ViewRenderer');


Expand All @@ -119,7 +145,7 @@ public function initView($e)


public static function prepareCompilerView($view, $config, $services) public static function prepareCompilerView($view, $config, $services)
{ {
$renderer = $services->get('ViewRenderer'); $renderer = $services->get('ViewPhpRenderer');
$view->addRenderingStrategy(function($e) use ($renderer) { $view->addRenderingStrategy(function($e) use ($renderer) {
return $renderer; return $renderer;
}, 100); }, 100);
Expand Down
2 changes: 1 addition & 1 deletion public/index.php
@@ -1,3 +1,3 @@
<?php <?php
require __DIR__ . '/../bootstrap.php'; $application = include __DIR__ . '/../bootstrap.php';
$application->run()->send(); $application->run()->send();

0 comments on commit 9d78241

Please sign in to comment.