Permalink
Browse files

Remove pluralization

- What you did
  • Loading branch information...
1 parent a3f23fd commit 805e3ae0ddc4a90a8a3a03a2ea270a98215d281f @weierophinney weierophinney committed Nov 22, 2011
View
@@ -0,0 +1,62 @@
+<?php
+
+namespace Contact;
+
+use InvalidArgumentException,
+ Zend\Module\Consumer\AutoloaderProvider;
+
+class Module implements AutoloaderProvider
+{
+ public function getAutoloaderConfig()
+ {
+ return array(
+ 'Zend\Loader\ClassMapAutoloader' => array(
+ __DIR__ . '/autoload_classmap.php'
+ ),
+ );
+ }
+
+ public function getConfig($env = null)
+ {
+ $config = include __DIR__ . '/configs/module.config.php';
+ if (null === $env) {
+ return $config;
+ }
+
+ if (!isset($config[$env])) {
+ throw new InvalidArgumentException(sprintf(
+ 'Unrecognized environment "%s" provided to %s',
+ $env,
+ __METHOD__
+ ));
+ }
+
+ return $config[$env];
+ }
+
+ public function getProvides()
+ {
+ return array(
+ 'name' => 'Blog',
+ 'version' => '0.1.0',
+ );
+ }
+
+ public function getDependencies()
+ {
+ return array(
+ 'php' => array(
+ 'required' => true,
+ 'version' => '>=5.3.1',
+ ),
+ 'ext/mongo' => array(
+ 'required' => true,
+ 'version' => '>=1.2.0',
+ ),
+ 'CommonResource' => array(
+ 'required' => true,
+ 'version' => '>=0.1.0',
+ )
+ );
+ }
+}
View
@@ -0,0 +1,5 @@
+<?php
+return array (
+ 'Contact\\Controller\\ContactController' => __DIR__ . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Contact' . DIRECTORY_SEPARATOR . 'Controller' . DIRECTORY_SEPARATOR . 'ContactController.php',
+ 'Contact\\Form\\ContactForm' => __DIR__ . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Contact' . DIRECTORY_SEPARATOR . 'Form' . DIRECTORY_SEPARATOR . 'ContactForm.php',
+);
View
@@ -0,0 +1,12 @@
+<?php
+return function ($class) {
+ static $map;
+ if (!$map) {
+ $map = include __DIR__ . '/autoload_classmap.php';
+ }
+
+ if (!isset($map[$class])) {
+ return false;
+ }
+ return include $map[$class];
+};
View
@@ -0,0 +1,2 @@
+<?php
+spl_autoload_register(include __DIR__ . '/autoload_function.php');
View
@@ -0,0 +1,125 @@
+<?php
+$config['production'] = array(
+'di' => array(
+ 'definition' => array('class' => array(
+ 'Contact\Controller\ContactController' => array(
+ 'setContactForm' => array(
+ 'form' => array(
+ 'required' => true,
+ 'type' => 'Contact\Form\ContactForm',
+ ),
+ ),
+ ),
+ 'Contact\Form\ContactForm' => array(
+ '__construct' => array(
+ 'options' => array(
+ 'required' => true,
+ 'type' => 'Zend\Captcha\ReCaptcha',
+ ),
+ ),
+ ),
+ 'Zend\Captcha\ReCaptcha' => array(
+ 'setPrivkey' => array(
+ 'privkey' => array(
+ 'required' => true,
+ 'type' => false,
+ ),
+ ),
+ 'setPubkey' => array(
+ 'pubkey' => array(
+ 'required' => true,
+ 'type' => false,
+ ),
+ ),
+ ),
+ 'Zend\Mail\Mail' => array(
+ 'addTo' => array(
+ 'email' => array(
+ 'type' => false,
+ 'required' => true,
+ ),
+ 'name' => array(
+ 'type' => false,
+ 'required' => false,
+ ),
+ ),
+ ),
+ )),
+ 'instance' => array(
+ 'alias' => array(
+ 'contact-contact' => 'Contact\Controller\ContactController',
+ 'view' => 'Zend\View\PhpRenderer',
+ 'view-resolver' => 'Zend\View\TemplatePathStack',
+ ),
+
+ 'Zend\Mail\Mail' => array('parameters' => array(
+ 'Zend\Mail\Mail::addTo:email' => 'EMAIL HERE',
+ 'Zend\Mail\Mail::addTo:name' => "NAME HERE",
+ )),
+
+ 'view' => array('parameters' => array(
+ 'resolver' => 'view-resolver',
+ )),
+
+ 'view-resolver' => array('parameters' => array(
+ 'paths' => array(
+ 'contact' => __DIR__ . '/../views',
+ ),
+ )),
+
+ 'Contact\Controller\ContactController' => array('parameters' => array(
+ 'mailer' => 'Zend\Mail\Mail',
+ 'form' => 'Contact\Form\ContactForm',
+ )),
+
+ 'Contact\Form\ContactForm' => array('parameters' => array(
+ 'recaptcha' => 'Zend\Captcha\ReCaptcha',
+ )),
+
+ 'Zend\Captcha\ReCaptcha' => array('parameters' => array(
+ 'pubkey' => 'RECAPTCHA_PUBKEY_HERE',
+ 'privkey' => 'RECAPTCHA_PRIVKEY_HERE',
+ )),
+ ),
+),
+
+'routes' => array(
+ 'contact-form' => array(
+ 'type' => 'Literal',
+ 'options' => array(
+ 'route' => '/contact',
+ 'defaults' => array(
+ 'controller' => 'contact-contact',
+ 'action' => 'index',
+ ),
+ ),
+ ),
+
+ 'contact-process' => array(
+ 'type' => 'Literal',
+ 'options' => array(
+ 'route' => '/contact/process',
+ 'defaults' => array(
+ 'controller' => 'contact-contact',
+ 'action' => 'process',
+ ),
+ ),
+ ),
+
+ 'contact-thank-you' => array(
+ 'type' => 'Literal',
+ 'options' => array(
+ 'route' => '/contact/thank-you',
+ 'defaults' => array(
+ 'controller' => 'contact-contact',
+ 'action' => 'thank-you',
+ ),
+ ),
+ ),
+),
+);
+$config['staging'] = $config['production'];
+$config['testing'] = $config['production'];
+$config['development'] = $config['production'];
+return $config;
+
@@ -0,0 +1,83 @@
+<?php
+$config['production'] = array(
+ 'di' => array('instance' => array(
+ 'alias' => array(
+ 'contact-contact' => 'Contact\Controller\ContactController',
+ ),
+
+ 'preferences' => array(
+ 'Zend\Mail\AbstractTransport' => 'Zend\Mail\Transport\Smtp',
+ ),
+
+ 'Zend\Mail\Mail' => array('methods' => array(
+ 'addTo' => array(
+ 'email' => 'your@emailhe.re',
+ 'name' => "Your Name Here",
+ ),
+ )),
+
+ 'Zend\Mail\Transport\Smtp' => array('methods' => array(
+ '__construct' => array(
+ 'host' => 'localhost',
+ 'config' => array(
+ 'port' => 25,
+ ),
+ ),
+ )),
+
+ 'Zend\View\PhpRenderer' => array(
+ 'methods' => array(
+ 'setResolver' => array(
+ 'resolver' => 'Zend\View\TemplatePathStack',
+ 'options' => array(
+ 'script_paths' => array(
+ 'contact' => __DIR__ . '/../views',
+ ),
+ ),
+ ),
+ ),
+ ),
+
+ 'Contact\Controller\ContactController' => array('parameters' => array(
+ 'mailer' => 'Zend\Mail\Mail',
+ 'transport' => 'Zend\Mail\Transport\Smtp',
+ )),
+ )),
+
+ 'routes' => array(
+ 'contact-form' => array(
+ 'type' => 'Zend\Mvc\Router\Http\Literal',
+ 'options' => array(
+ 'route' => '/contact',
+ 'defaults' => array(
+ 'controller' => 'contact-contact',
+ 'action' => 'index',
+ ),
+ ),
+ ),
+ 'contact-process' => array(
+ 'type' => 'Zend\Mvc\Router\Http\Literal',
+ 'options' => array(
+ 'route' => '/contact/process',
+ 'defaults' => array(
+ 'controller' => 'contact-contact',
+ 'action' => 'process',
+ ),
+ ),
+ ),
+ 'contact-thank-you' => array(
+ 'type' => 'Zend\Mvc\Router\Http\Literal',
+ 'options' => array(
+ 'route' => '/contact/thank-you',
+ 'defaults' => array(
+ 'controller' => 'contact-contact',
+ 'action' => 'thank-you',
+ ),
+ ),
+ ),
+ ),
+);
+$config['staging'] = $config['production'];
+$config['testing'] = $config['production'];
+$config['development'] = $config['production'];
+return $config;
@@ -0,0 +1,71 @@
+<?php
+
+namespace Contact\Controller;
+
+use Contact\Form\ContactForm,
+ Zend\Mail\AbstractTransport as Transport,
+ Zend\Mail\Mail as Mailer,
+ Zend\Mvc\Controller\ActionController;
+
+class ContactController extends ActionController
+{
+ protected $form;
+ protected $mailer;
+ protected $transport;
+
+ public function setMailer(Mailer $mailer)
+ {
+ $this->mailer = $mailer;
+ }
+
+ public function setMailTransport(Transport $transport)
+ {
+ $this->transport = $transport;
+ }
+
+ public function indexAction()
+ {
+ return array('form' => $this->form);
+ }
+
+ public function processAction()
+ {
+ if (!$this->request->isPost()) {
+ $this->response->setStatusCode(302);
+ $this->response->headers()->addHeaderLine('Location', '/contact');
+ }
+ $post = $this->request->post()->toArray();
+ $form = $this->form;
+ if (!$form->isValid($post)) {
+ $this->getEvent()->getRouteMatch()->setParam('action', 'index');
+ return array(
+ 'error' => true,
+ 'form' => $form
+ );
+ }
+
+ // send email...
+ $values = $form->getValues();
+ $from = $values['from'];
+ $subject = '[Contact Form] ' . $values['subject'];
+ $body = $values['body'];
+
+ $this->mailer->setFrom($from)
+ ->setReplyTo($from)
+ ->setSubject($subject)
+ ->setBodyText($body);
+ $this->mailer->send($this->transport);
+
+ return $this->redirect()->toRoute('contact-thank-you');
+ }
+
+ public function thankYouAction()
+ {
+ // do nothing...
+ }
+
+ public function setContactForm(ContactForm $form)
+ {
+ $this->form = $form;
+ }
+}
Oops, something went wrong.

0 comments on commit 805e3ae

Please sign in to comment.