Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mtymek committed Dec 18, 2011
1 parent fffe111 commit fef18ad
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
32 changes: 32 additions & 0 deletions README.md
@@ -0,0 +1,32 @@
ZfTwig Module
=============

This Zend Framework 2 module allows you to use Twig templates in your projects.

It is shipped with custom view listener, so main application module simply needs to do
is setting up some variables in Module.php:


public function init(Manager $moduleManager)
{
$events = StaticEventManager::getInstance();
$events->attach('bootstrap', 'bootstrap', array($this, 'initializeView'));
}

public function initializeView($e)
{
$app = $e->getParam('application');
$locator = $app->getLocator();
$view = $locator->get('view');
$view->getEnvironment()->getLoader()->addPath(__DIR__ . '/views');

$url = $view->plugin('url');
$url->setRouter($app->getRouter());

$view->plugin('headTitle')->setSeparator(' - ')
->setAutoEscape(false)
->append('Application');
}


Full example can be found here: https://github.com/mtymek/ZfTwigExample
5 changes: 0 additions & 5 deletions readme.md

This file was deleted.

11 changes: 1 addition & 10 deletions src/ZfTwig/View/Listener.php
Expand Up @@ -40,8 +40,8 @@ public function displayExceptions()
public function attach(EventCollection $events)
{
$this->listeners[] = $events->attach('dispatch.error', array($this, 'renderError'));
$this->listeners[] = $events->attach('dispatch', array($this, 'render404'), -1000);
$this->listeners[] = $events->attach('dispatch', array($this, 'renderView'), -50);
$this->listeners[] = $events->attach('dispatch', array($this, 'render404'), -1000);
}

public function detach(EventCollection $events)
Expand All @@ -53,15 +53,6 @@ public function detach(EventCollection $events)
}
}

public function detachStaticListeners(StaticEventCollection $events)
{
foreach ($this->staticListeners as $i => $info) {
list($id, $handler) = $info;
$events->detach($id, $handler);
unset($this->staticListeners[$i]);
}
}

public function renderView(MvcEvent $e)
{
$response = $e->getResponse();
Expand Down

0 comments on commit fef18ad

Please sign in to comment.