> $bootstrap = $this->getInvokeArg('bootstrap'); For some reason that works beautifully on my development machine but not on the production server (shared hosting).
Fortunately this is a very small application so I'm able to work around it easily by putting my config object in Zend_Registry. But I'm clueless as to why the server doesn't want to play along ... On Mon, Nov 30, 2009 at 8:03 PM, Matthew Weier O'Phinney <matt...@zend.com> wrote: > -- Eugene Morgan <eugenemorganrea...@gmail.com> wrote > (on Monday, 30 November 2009, 06:35 PM -0600): >> I am working on a contact form in ZF 1.9. In one of my actions, I am >> trying to access the bootstrap by >> $this->getFrontController()->getParam('bootstrap') > > Not sure why it's not working, but there's an easier way: > > $bootstrap = $this->getInvokeArg('bootstrap'); > >> I made some changes to the application.ini file that shouldn't affect >> anything ... but now the code above is not returning the bootstrap. In >> fact, $this->getFrontController() returns NULL -- I am not sure why? >> It was working fine before ... >> >> Here is my application.ini file >> [production] >> phpSettings.display_startup_errors = 0 >> phpSettings.display_errors = 0 >> phpSettings.date.timezone = "America/Chicago" >> >> includePaths.library = APPLICATION_PATH "/../library" >> bootstrap.path = APPLICATION_PATH "/Bootstrap.php" >> bootstrap.class = "Bootstrap" >> >> resources.frontController.controllerDirectory = APPLICATION_PATH >> "/controllers" >> resources.layout.layout = "layout" >> resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts" >> >> contactMail.fromAddress = cont...@xyz.com >> contactMail.fromName = Contact form >> contactMail.toAddress = a...@abc.com >> contactMail.toName = Some Name >> contactMail.subject = "Contact Form Message on xyz.com" >> >> [staging : production] >> >> [testing : production] >> phpSettings.display_startup_errors = 1 >> phpSettings.display_errors = 1 >> >> [development : production] >> phpSettings.display_startup_errors = 1 >> phpSettings.display_errors = 1 >> >> Here is the code in the action method: >> >> >> public function createAction() >> { >> if (!$this->_request->isPost()) { >> return $this->_forward('new'); >> } >> >> $form = new Form_Contact(); >> $formData = $this->_request->getPost(); >> if (!$form->isValid($formData)) { >> return $this->_forward('new'); >> } >> >> // Check for honeypot to avoid spam >> if ($form->getValue('altEmail')) { >> return $this->_forward('spam'); >> } >> >> $view = new Zend_View(); >> $path = APPLICATION_PATH . '/views/scripts'; >> $view->setScriptPath($path); >> $view->name = $form->getValue('contactName'); >> $view->phone = $form->getValue('phone'); >> $view->email = $form->getValue('email'); >> $view->comments = $form->getValue('comments'); >> >> $bootstrap = $this->getFrontController()->getParam('bootstrap'); >> if ($bootstrap->getEnvironment() == 'production') { >> $config = new Zend_Config($bootstrap->getOption('smtp')); >> $mail = new Zend_Mail('utf-8'); >> $mail->setFrom($config->fromAddress, $config->fromName); >> $mail->addTo($config->toAddress, $config->toName); >> $mail->setSubject($config->subject); >> $mail->setBodyHtml($view->render('mail/contact.phtml')); >> $mail->send(); >> } >> >> $this->_redirector->gotoSimple('show'); >> } >> > > -- > Matthew Weier O'Phinney > Project Lead | matt...@zend.com > Zend Framework | http://framework.zend.com/ >