Created
January 9, 2013 21:52
-
-
Save AlexTiTanium/4497294 to your computer and use it in GitHub Desktop.
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
<?php | |
namespace lib\Templates\EngineExtensions; | |
use Twig_Extension; | |
use lib\Core\IncluderService; | |
use Twig_Function_Method; | |
class ViewHelper extends Twig_Extension { | |
/** | |
* @return array | |
*/ | |
public function getFunctions(){ | |
return array( | |
'addCss' => new Twig_Function_Method($this, 'addCss',array('is_safe' => array('html'))), | |
'addJs' => new Twig_Function_Method($this, 'addJs',array('is_safe' => array('html'))) | |
); | |
} | |
/** | |
* @param $path | |
* | |
* @return string | |
*/ | |
public function addCss($path){ | |
if(is_array($path)){ | |
$pathArray = array(); | |
foreach($path as $itemPath){ | |
$pathArray[] = $this->addCss($itemPath); | |
} | |
return implode("\n", $pathArray); | |
} | |
return IncluderService::$skin->css($path); | |
} | |
/** | |
* @param $path | |
* | |
* @return string | |
*/ | |
public function addJs($path){ | |
if(is_array($path)){ | |
$pathArray = array(); | |
foreach($path as $itemPath){ | |
$pathArray[] = $this->addJs($itemPath); | |
} | |
return implode("\n", $pathArray); | |
} | |
return IncluderService::$skin->js($path); | |
} | |
/** | |
* ViewHelper::getName() | |
* | |
* @return string | |
*/ | |
public function getName(){ | |
return 'ViewHelper'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment