Smarty.php 917 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\Core\Traits;
  3. use ThurData\Servers\KerioEmail\Core\ServiceLocator;
  4. trait Smarty
  5. {
  6. /**
  7. * @var null|\ThurData\Servers\KerioEmail\Core\Http\View\Smarty
  8. */
  9. protected $smarty = null;
  10. public function loadSmarty()
  11. {
  12. if ($this->smarty === null)
  13. {
  14. $this->smarty = ServiceLocator::call('smarty');
  15. if (property_exists($this, 'lang') && method_exists($this, 'loadLang'))
  16. {
  17. $this->loadLang();
  18. $this->smarty->setLang($this->lang);
  19. }
  20. else
  21. {
  22. $lang = ServiceLocator::call('lang');
  23. $this->smarty->setLang($lang);
  24. }
  25. }
  26. }
  27. public function getSmarty()
  28. {
  29. if ($this->smarty === null)
  30. {
  31. $this->loadSmarty();
  32. }
  33. return $this->smarty;
  34. }
  35. }