lib/composer/PageBundle/src/VisualMedia/PageBundle/Service/PageLayoutProvider.php line 54

Open in your IDE?
  1. <?php
  2. /**
  3. * Page Layout Provider
  4. *
  5. * @author Vincent van Waasbergen <v.vanwaasbergen@visualmedia.nl>
  6. */
  7. namespace VisualMedia\PageBundle\Service;
  8. use VisualMedia\LisaBundle\Component\Interfaces\ServiceInterface;
  9. /**
  10. * Page Layout Provider
  11. */
  12. class PageLayoutProvider implements ServiceInterface
  13. {
  14. const SERVICE_ID = 'visualmedia.lisa.page_layout_provider';
  15. const DEFAULT_TEMPLATE_KEY = 'default';
  16. const DEFAULT_TEMPLATE_PATH = '@VisualMediaPage/Page/view.html.twig';
  17. /**
  18. * Layouts
  19. * @var array
  20. */
  21. protected $layouts = array(self::DEFAULT_TEMPLATE_KEY => self::DEFAULT_TEMPLATE_PATH);
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public static function getServiceId() : string
  26. {
  27. return self::SERVICE_ID;
  28. }
  29. /**
  30. * Get Layouts
  31. *
  32. * @return array
  33. */
  34. public function getLayouts() : array
  35. {
  36. return $this->layouts;
  37. }
  38. /**
  39. * Get Layout
  40. *
  41. * @param string $key
  42. *
  43. * @return string
  44. */
  45. public function getLayout(?string $key) : ?string
  46. {
  47. return $this->layouts[$key] ?? $this->layouts[self::DEFAULT_TEMPLATE_KEY];
  48. }
  49. /**
  50. * Add Layout
  51. *
  52. * @param string $key
  53. * @param string $template
  54. *
  55. * @return void
  56. */
  57. public function addLayout($key, $template) : void
  58. {
  59. $this->layouts[$key] = $template;
  60. }
  61. }