Guest User

Untitled

a guest
Sep 3rd, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. Multi Stage with Zend Framework - where to configure/store form emails?
  2. $this->request->setMethod('POST')
  3. ->setPost(array(
  4. 'name'
  5. => 'Some Name',
  6. 'email'
  7. => 'contact@email.com',
  8. 'message'
  9. => "This is my test message."
  10. ));
  11. $this->dispatch('/about/contact');
  12.  
  13. [production]
  14. contact.email.address = "trueemail@email.com"
  15. contact.email.name = "John Stuart"
  16.  
  17. joinus.email.address = "anotheremail@email.com"
  18. joinus.email.name = "Patricia Bill"
  19.  
  20.  
  21. [development : production]
  22. contact.email.address = "my@email.com"
  23. contact.email.name = "Devname"
  24.  
  25. joinus.email.address = "my@email.com"
  26. joinus.email.name = "Devname"
  27.  
  28. if (APPLICATION_ENV == 'development') {
  29. $email = 'yourtestemail@example.com'; // your test email address
  30. } else {
  31. $email = 'normalemail@example.com'; // whatever the email should be
  32. }
  33.  
  34. class Yourapp_Form extends Zend_Form
  35. {
  36. protected $_recipientEmail;
  37.  
  38. public function setRecipientEmail($email)
  39. {
  40. $this->_recipientEmail = $email;
  41. }
  42.  
  43. public function getRecipientEmail()
  44. {
  45. if (APPLICATION_ENV == 'develpoment') {
  46. return 'yourtestemail@example.com';
  47. } else {
  48. return $this->_recipientEmail;
  49. }
  50. }
  51. }
  52.  
  53. class Yourapp_Contact_Form extends Yourapp_Form
  54. {
  55. public function init()
  56. {
  57. $this->addElement([...]);
  58. $this->setRecipientEmail('foo@example.com'); // <-- production email address
  59. }
  60. }
  61.  
  62. [development]
  63. resources.log.stream.filterName = "Priority"
  64. resources.log.stream.filterParams.priority = Zend_Log::DEBUG
  65. [production]
  66. resources.log.stream.filterName = "Priority"
  67. resources.log.stream.filterParams.priority = Zend_Log::DEBUG
  68.  
  69. [production]
  70. app.contacts.service1.name = "Paul Dupont"
  71. app.contacts.service1.email = "paul.dupont@example.com"
  72. app.contacts.service1.company = "Another Best Company"
  73. app.contacts.service1.name = "Kristina Dupuis"
  74. app.contacts.service1.email = "k.dupuis@example.com"
  75. [development]
  76. app.contacts.service1.name = "Me"
  77. app.contacts.service1.email = "me@example.com"
  78. app.contacts.service1.company = "THE best company"
  79. app.contacts.service1.name = "Myself"
  80. app.contacts.service1.email = "myself@example.com"
  81.  
  82. interface Service // Service means here the competent service of your company
  83. {
  84.  
  85. public function getEmail() {}
  86.  
  87. public function getContactName() {}
  88.  
  89. public function getCompanyName() {}
  90.  
  91. }
  92.  
  93. // usage, somewhere in your code :
  94. $this->request->setMethod('POST')
  95. ->setPost(array(
  96. 'name' => $serviceService->getService('contactus')->getContactName(),
  97. 'email' => $serviceService->getService('contactus')->getEmail(),
  98. 'message' => "This is my test message."
  99. ));
  100. $this->dispatch('/about/contact');
Add Comment
Please, Sign In to add comment