Skip to content

Instantly share code, notes, and snippets.

@yuuan
Created February 13, 2014 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuuan/8972485 to your computer and use it in GitHub Desktop.
Save yuuan/8972485 to your computer and use it in GitHub Desktop.
Phalcon の project/app/config/services.php を編集して Volt に date フィルターを追加してみた。
<?php
// ...
/**
* Setting up the view component
*/
$di->set('view', function () use ($config) {
$view = new View();
$view->setViewsDir($config->application->viewsDir);
$view->registerEngines(array(
'.volt' => function ($view, $di) use ($config) {
$volt = new VoltEngine($view, $di);
$volt->setOptions(array(
'compiledPath' => $config->application->cacheDir,
'compiledSeparator' => '_'
));
$compiler = $volt->getCompiler();
$compiler->addFilter('date', function($resolvedArgs, $exprArgs) {
$args = explode(',', $resolvedArgs . ", 'Y/m/d H:i:s'");
return "date($args[1], strtotime($args[0]))";
});
return $volt;
},
'.phtml' => 'Phalcon\Mvc\View\Engine\Php'
));
return $view;
}, true);
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment