Mail.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. *
  4. * Cube Framework $Id$ ogzubZwehP/Dbar/vhFenwBJAAkAUl0ok54nV45kx1k=
  5. *
  6. * @link http://codecu.be/framework
  7. * @copyright Copyright (c) 2014 CodeCube SRL
  8. * @license http://codecu.be/framework/license Commercial License
  9. *
  10. * @version 1.0
  11. */
  12. /**
  13. * mail resource management class
  14. */
  15. namespace Cube\Application\Resource;
  16. use Cube\Mail as MailObject;
  17. class Mail extends AbstractResource
  18. {
  19. /**
  20. *
  21. * mail object
  22. *
  23. * @var \Cube\Mail
  24. */
  25. protected $_mail;
  26. /**
  27. *
  28. * initialize mail resource
  29. *
  30. * @return \Cube\Mail
  31. */
  32. public function init()
  33. {
  34. if (!$this->_mail instanceof MailObject) {
  35. $this->_mail = new MailObject();
  36. if (isset($this->_options['mail']['transport'])) {
  37. $this->_mail->setTransport($this->_options['mail']['transport']);
  38. $this->_mail->getTransport()->setOptions($this->_options['mail']);
  39. $view = $this->_mail->getView();
  40. if (isset($this->_options['mail']['layout_file'])) {
  41. $view->setLayout($this->_options['mail']['layout_file']);
  42. }
  43. if (isset($this->_options['mail']['layouts_path'])) {
  44. $view->setLayoutsPath($this->_options['mail']['layouts_path']);
  45. }
  46. if (isset($this->_options['mail']['views_path'])) {
  47. $view->setViewsPath($this->_options['mail']['views_path']);
  48. }
  49. }
  50. }
  51. return $this->_mail;
  52. }
  53. }