Skip to content

Commit

Permalink
Updated for beta5/pre-rc1
Browse files Browse the repository at this point in the history
- 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
weierophinney committed Jul 13, 2012
1 parent c253916 commit be34220
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
9 changes: 5 additions & 4 deletions config/module.config.php
Expand Up @@ -27,9 +27,9 @@
*/
),
),
'controller' => array(
'controllers' => array(
'factories' => array(
'PhlyContact\Controller\ContactController' => 'PhlyContact\Service\ContactControllerFactory',
'PhlyContact\Controller\Contact' => 'PhlyContact\Service\ContactControllerFactory',
),
),
'router' => array(
Expand All @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions src/PhlyContact/Controller/ContactController.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand All @@ -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())
) {
Expand Down
16 changes: 8 additions & 8 deletions src/PhlyContact/Form/ContactForm.php
Expand Up @@ -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',
),
));
Expand Down
1 change: 0 additions & 1 deletion src/PhlyContact/Service/ContactMailTransportFactory.php
Expand Up @@ -48,4 +48,3 @@ public function createService(ServiceLocatorInterface $services)
return $transport;
}
}

0 comments on commit be34220

Please sign in to comment.