initial commit
This commit is contained in:
commit
e869a1cab4
107 changed files with 9029 additions and 0 deletions
56
app/library/ViewHelper/Volt/Extension.php
Normal file
56
app/library/ViewHelper/Volt/Extension.php
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace ViewHelper\Volt;
|
||||
|
||||
use \Phalcon\Di\InjectionAwareInterface;
|
||||
|
||||
class Extension implements InjectionAwareInterface
|
||||
{
|
||||
protected $_serviceKey = 'viewHelper';
|
||||
|
||||
/**
|
||||
* @var \Phalcon\DiInterface
|
||||
*/
|
||||
protected $_di;
|
||||
|
||||
public function __construct(\Phalcon\DiInterface $dependencyInjector)
|
||||
{
|
||||
$this->_di = $dependencyInjector;
|
||||
|
||||
if (!$this->_di->has($this->_serviceKey)) {
|
||||
$this->_di->set($this->_serviceKey, '\ViewHelper\Service', true);
|
||||
}
|
||||
}
|
||||
|
||||
public function compileFunction($name, $args)
|
||||
{
|
||||
// Get the view helper service.
|
||||
$service = $this->_di->getShared($this->_serviceKey);
|
||||
|
||||
// Search for the helper in service.
|
||||
if ($service->has($name)) {
|
||||
return "\$this->{$this->_serviceKey}->{$name}({$args})";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the dependency injector
|
||||
*
|
||||
* @param mixed $dependencyInjector
|
||||
*/
|
||||
public function setDI(\Phalcon\DiInterface $dependencyInjector)
|
||||
{
|
||||
$this->_di = $dependencyInjector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the internal dependency injector
|
||||
*
|
||||
* @return \Phalcon\DiInterface
|
||||
*/
|
||||
public function getDI()
|
||||
{
|
||||
return $this->_di;
|
||||
}
|
||||
}
|
||||
Reference in a new issue