Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Drupal\example\Controller;
  4.  
  5. use Drupal\Core\Controller\ControllerBase;
  6. use Symfony\Component\DependencyInjection\ContainerInterface;
  7.  
  8. class ExampleController extends ControllerBase
  9. {
  10. protected $example_service;
  11.  
  12. public function __construct($example_service)
  13. {
  14. $this->example_service = $example_service;
  15. }
  16.  
  17. public static function create(ContainerInterface $container)
  18. {
  19. return new static(
  20. $container->get('example.example_service')
  21. );
  22. }
  23.  
  24. public function homepage() {
  25. return array(
  26. '#markup' => t(
  27. 'Hello @value!',
  28. array('@value' => $this->example_service->getValue())
  29. )
  30. );
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement