Archived
1
0
Fork 0
This repository has been archived on 2026-04-03. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
httpcb/app/library/ViewHelper/Volt/Extension.php

57 lines
1.2 KiB
PHP

<?php
namespace Httpcb\ViewHelper\Volt;
use Phalcon\DiInterface,
Phalcon\Di\InjectionAwareInterface;
class Extension implements InjectionAwareInterface
{
protected $_serviceKey = 'HttpcbViewHelper';
/**
* @var DiInterface
*/
protected $_di;
public function __construct(DiInterface $dependencyInjector)
{
$this->_di = $dependencyInjector;
if (!$this->_di->has($this->_serviceKey)) {
$this->_di->set($this->_serviceKey, 'Httpcb\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(DiInterface $dependencyInjector)
{
$this->_di = $dependencyInjector;
}
/**
* Returns the internal dependency injector
*
* @return \Phalcon\DiInterface
*/
public function getDI()
{
return $this->_di;
}
}