Skip to content

Instantly share code, notes, and snippets.

@dmouse
Created February 16, 2014 16:59
Show Gist options
  • Select an option

  • Save dmouse/9037206 to your computer and use it in GitHub Desktop.

Select an option

Save dmouse/9037206 to your computer and use it in GitHub Desktop.
<?php
namespace Drupal\badcamp\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\ExtraModule\Annotation\Permission;
use Drupal\Core\Template\TwigEnvironment;
class DefaultController extends ControllerBase implements ContainerInjectionInterface {
/**
* @var \TwigEnvironment
*/
protected $twig;
public function __construct(TwigEnvironment $twig) {
$this->twig = $twig;
}
public static function create(ContainerInterface $container){
return new static(
$container->get('twig')
);
}
/**
* helloAction
* @param string $name Get
* @return [type] [description]
*
* @Permission("access content")
*/
public function helloAction($name) {
$template = $this->twig->loadTemplate('badcamp::hello.html.twig');
return $template->render(array(
'name' => $name
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment