From 1990517b2263a080946853ed697a6d687262ae80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 31 Jan 2015 15:36:04 +0100 Subject: remove Acme and AppBundle --- .../DemoBundle/Twig/Extension/DemoExtension.php | 81 ---------------------- 1 file changed, 81 deletions(-) delete mode 100644 src/Acme/DemoBundle/Twig/Extension/DemoExtension.php (limited to 'src/Acme/DemoBundle/Twig/Extension') diff --git a/src/Acme/DemoBundle/Twig/Extension/DemoExtension.php b/src/Acme/DemoBundle/Twig/Extension/DemoExtension.php deleted file mode 100644 index e6ce94f6..00000000 --- a/src/Acme/DemoBundle/Twig/Extension/DemoExtension.php +++ /dev/null @@ -1,81 +0,0 @@ -loader = $loader; - } - - public function setController($controller) - { - $this->controller = $controller; - } - - /** - * {@inheritdoc} - */ - public function getFunctions() - { - return array( - new \Twig_SimpleFunction('code', array($this, 'getCode'), array('is_safe' => array('html'))), - ); - } - - public function getCode($template) - { - // highlight_string highlights php code only if 'getControllerCode(), true); - $controller = str_replace('<?php    ', '    ', $controller); - - $template = htmlspecialchars($this->getTemplateCode($template), ENT_QUOTES, 'UTF-8'); - - // remove the code block - $template = str_replace('{% set code = code(_self) %}', '', $template); - - return <<Controller Code

-
$controller
- -

Template Code

-
$template
-EOF; - } - - protected function getControllerCode() - { - $class = get_class($this->controller[0]); - if (class_exists('CG\Core\ClassUtils')) { - $class = ClassUtils::getUserClass($class); - } - - $r = new \ReflectionClass($class); - $m = $r->getMethod($this->controller[1]); - - $code = file($r->getFilename()); - - return ' '.$m->getDocComment()."\n".implode('', array_slice($code, $m->getStartline() - 1, $m->getEndLine() - $m->getStartline() + 1)); - } - - protected function getTemplateCode($template) - { - return $this->loader->getSource($template->getTemplateName()); - } - - /** - * Returns the name of the extension. - * - * @return string The extension name - */ - public function getName() - { - return 'demo'; - } -} -- cgit v1.2.3