Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Checks for authenticated user before displaying form
- Loading branch information
1 parent
fca61a5
commit 942a301
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace PhlyPeep\Service; | ||
|
||
use PhlyPeep\View\PeepForm; | ||
use Zend\ServiceManager\FactoryInterface; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
|
||
class PeepViewFormFactory implements FactoryInterface | ||
{ | ||
public function createService(ServiceLocatorInterface $services) | ||
{ | ||
$authService = $services->get('zfcuser_auth_service'); | ||
$helper = new PeepForm(); | ||
$helper->setAuthService($authService); | ||
return $helper; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace PhlyPeep\View; | ||
|
||
use Zend\View\Helper\AbstractHelper; | ||
|
||
class PeepForm extends AbstractHelper | ||
{ | ||
protected $auth; | ||
|
||
public function setAuthService(AuthenticationService $auth) | ||
{ | ||
$this->auth = $auth; | ||
} | ||
|
||
public function __invoke($form, $template = 'phly-peep/peep/form') | ||
{ | ||
if (!$this->auth || $this->auth->hasIdentity()) { | ||
return ''; | ||
} | ||
|
||
return $this->view->render($template, array('form' => $form)); | ||
} | ||
} |