Skip to content
Browse files

Updated for beta5/pre-rc1

- ContactController
  - extend AbstractActionController
  - use getPost, getHeaders, etc.
- ContactForm
  - use new form element types
  - labels are now options, not attributes
  - captchas are options, not attributes
- PSR1/2 fixes
- Use controller aliases built from the namespace
  • Loading branch information...
1 parent c253916 commit be34220ee3b849a59d5d75d15f32ab70c4ecbec2 @weierophinney weierophinney committed Jul 13, 2012
View
9 config/module.config.php
@@ -27,9 +27,9 @@
*/
),
),
- 'controller' => array(
+ 'controllers' => array(
'factories' => array(
- 'PhlyContact\Controller\ContactController' => 'PhlyContact\Service\ContactControllerFactory',
+ 'PhlyContact\Controller\Contact' => 'PhlyContact\Service\ContactControllerFactory',
),
),
'router' => array(
@@ -39,8 +39,9 @@
'options' => array(
'route' => '/contact',
'defaults' => array(
- 'controller' => 'PhlyContact\Controller\ContactController',
- 'action' => 'index',
+ '__NAMESPACE__' => 'PhlyContact\Controller',
+ 'controller' => 'Contact',
+ 'action' => 'index',
),
),
'may_terminate' => true,
View
16 src/PhlyContact/Controller/ContactController.php
@@ -2,13 +2,13 @@
namespace PhlyContact\Controller;
-use PhlyContact\Form\ContactForm,
- Zend\Mail\Transport,
- Zend\Mail\Message as Message,
- Zend\Mvc\Controller\ActionController,
- Zend\View\Model\ViewModel;
+use PhlyContact\Form\ContactForm;
+use Zend\Mail\Transport;
+use Zend\Mail\Message as Message;
+use Zend\Mvc\Controller\AbstractActionController;
+use Zend\View\Model\ViewModel;
-class ContactController extends ActionController
+class ContactController extends AbstractActionController
{
protected $form;
protected $message;
@@ -37,7 +37,7 @@ public function processAction()
return $this->redirect()->toRoute('contact');
}
- $post = $this->request->post();
+ $post = $this->request->getPost();
$form = $this->form;
$form->setData($post);
if (!$form->isValid()) {
@@ -57,7 +57,7 @@ public function processAction()
public function thankYouAction()
{
- $headers = $this->request->headers();
+ $headers = $this->request->getHeaders();
if (!$headers->has('Referer')
|| !preg_match('#/contact$#', $headers->get('Referer')->getFieldValue())
) {
View
16 src/PhlyContact/Form/ContactForm.php
@@ -30,40 +30,40 @@ public function init()
$this->add(array(
'name' => 'from',
- 'attributes' => array(
+ 'type' => 'Zend\Form\Element\Text',
+ 'options' => array(
'label' => 'From:',
- 'type' => 'text',
),
));
$this->add(array(
'name' => 'subject',
- 'attributes' => array(
+ 'type' => 'Zend\Form\Element\Text',
+ 'options' => array(
'label' => 'Subject:',
- 'type' => 'text',
),
));
$this->add(array(
'name' => 'body',
- 'attributes' => array(
+ 'type' => 'Zend\Form\Element\Textarea',
+ 'options' => array(
'label' => 'Your message:',
- 'type' => 'textarea',
),
));
$captcha = new Element\Captcha('captcha');
$captcha->setCaptcha($this->captchaAdapter);
- $captcha->setAttribute('label', 'Please verify you are human.');
+ $captcha->setOptions(array('label' => 'Please verify you are human.'));
$this->add($captcha);
$this->add(new Element\Csrf('csrf'));
$this->add(array(
'name' => 'Send',
+ 'type' => 'Zend\Form\Element\Submit',
'attributes' => array(
- 'type' => 'submit',
'value' => 'Send',
),
));
View
1 src/PhlyContact/Service/ContactMailTransportFactory.php
@@ -48,4 +48,3 @@ public function createService(ServiceLocatorInterface $services)
return $transport;
}
}
-

0 comments on commit be34220

Please sign in to comment.
Something went wrong with that request. Please try again.