This repository has been archived by the owner on Sep 5, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
33 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters