Permalink
Browse files

Update SM factory for Service\EmailVerification to pull Form dependency

Why: The Form depends on a validator which uses the ZfcUser mapper.  When running the test suite, both the ZendDb and DoctrineORM modules are loaded, and the DoctrineORM mapper overwrites the SM alias for the ZendDb mapper, causing the Form instantiation to fail.
  • Loading branch information...
1 parent 9608601 commit 5c61d48b5a2ec27398fe876a5a5b171b486f52b1 @adamlundrigan adamlundrigan committed Oct 25, 2012
Showing with 15 additions and 1 deletion.
  1. +1 −1 Module.php
  2. +14 −0 src/CdliTwoStageSignup/Service/EmailVerification.php
View
@@ -77,8 +77,8 @@ public function getServiceConfig()
},
'cdlitwostagesignup_ev_service' => function($sm) {
$obj = new Service\EmailVerification();
+ $obj->setServiceLocator($sm);
$obj->setEmailVerificationMapper($sm->get('cdlitwostagesignup_ev_modelmapper'));
- $obj->setEmailVerificationForm($sm->get('cdlitwostagesignup_ev_form'));
$obj->setMessageRenderer($sm->get('Zend\View\Renderer\PhpRenderer'));
$obj->setMessageTransport($sm->get('Zend\Mail\Transport\Sendmail'));
$obj->setEmailMessageOptions($sm->get('cdlitwostagesignup_module_options'));
@@ -13,6 +13,7 @@
use Zend\View\Renderer\RendererInterface as ViewRenderer;
use CdliTwoStageSignup\Options\EmailOptionsInterface;
use CdliTwoStageSignup\Form\EmailVerification as EvrForm;
+use Zend\ServiceManager\ServiceLocatorInterface;
class EmailVerification extends EventProvider
{
@@ -24,6 +25,7 @@ class EmailVerification extends EventProvider
protected $emailMessageOptions;
protected $emailRenderer;
protected $emailTransport;
+ protected $locator;
public function findByRequestKey($token)
{
@@ -107,6 +109,9 @@ public function setEmailVerificationForm(EvrForm $f)
public function getEmailVerificationForm()
{
+ if (is_null($this->evrForm)) {
+ $this->evrForm = $this->getServiceLocator()->get('cdlitwostagesignup_ev_form');
+ }
return $this->evrForm;
}
@@ -133,5 +138,14 @@ public function setEmailMessageOptions(EmailOptionsInterface $opt)
return $this;
}
+ public function setServiceLocator(ServiceLocatorInterface $sl)
+ {
+ $this->locator = $sl;
+ return $this;
+ }
+ public function getServiceLocator()
+ {
+ return $this->locator;
+ }
}

0 comments on commit 5c61d48

Please sign in to comment.