This repository has been archived by the owner on Mar 14, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Simple controller implementation -- checks to see if given page resolves (after giving it a prefix), and, if so, sets that as the template for the returned view model. - Provided initial static page for "participate" overview, mapping to "/community". Includes a sidebar.
- Loading branch information
1 parent
0f298e2
commit 5c90c58
Showing
9 changed files
with
218 additions
and
2 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,22 @@ | ||
<?php | ||
return array( | ||
'router' => array( | ||
'routes' => array( | ||
'participate' => array( | ||
'type' => 'Zend\Mvc\Router\Http\Literal', | ||
'options' => array( | ||
'route' => '/community', | ||
'defaults' => array( | ||
'__NAMESPACE__' => 'PageController\Controller', | ||
'controller' => 'Page', | ||
'page' => 'participate', | ||
), | ||
'may_terminate' => true, | ||
'child_routes' => array( | ||
/* other child routes forthcoming */ | ||
), | ||
), | ||
), | ||
), | ||
), | ||
); |
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,36 @@ | ||
<?php | ||
|
||
namespace PageController; | ||
|
||
class Module | ||
{ | ||
public function getAutoloaderConfig() | ||
{ | ||
return array( | ||
'Zend\Loader\StandardAutoloader' => array( | ||
'namespaces' => array( | ||
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, | ||
), | ||
), | ||
); | ||
} | ||
|
||
public function getConfig() | ||
{ | ||
return include __DIR__ . '/config/module.config.php'; | ||
} | ||
|
||
public function getControllerConfig() | ||
{ | ||
return array('factories' => array( | ||
'PageController\Controller\Page' => function ($sm) { | ||
$services = $sm->getServiceLocator(); | ||
$resolver = $services->get('ViewResolver'); | ||
|
||
$controller = new Controller\PageController(); | ||
$controller->setResolver($resolver); | ||
return $controller; | ||
}, | ||
)); | ||
} | ||
} |
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,8 @@ | ||
<?php | ||
return array( | ||
'view_manager' => array( | ||
'template_path_stack' => array( | ||
'page-controller' => __DIR__ . '/../view', | ||
), | ||
), | ||
); |
77 changes: 77 additions & 0 deletions
77
module/PageController/src/PageController/Controller/PageController.php
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,77 @@ | ||
<?php | ||
|
||
namespace PageController\Controller; | ||
|
||
use Zend\Mvc\Controller\AbstractController; | ||
use Zend\Mvc\MvcEvent; | ||
use Zend\View\Resolver\ResolverInterface; | ||
use Zend\View\Model\ViewModel; | ||
|
||
class PageController extends AbstractController | ||
{ | ||
/** | ||
* @var ResolverInterface | ||
*/ | ||
protected $resolver; | ||
|
||
/** | ||
* Set the resolver | ||
* | ||
* @param ResolverInterface $resolver | ||
* @return PageController | ||
*/ | ||
public function setResolver(ResolverInterface $resolver) | ||
{ | ||
$this->resolver = $resolver; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Listen to dispatch event | ||
* | ||
* Retrieves "page" parameter from route matches. If none found, assumes | ||
* a 404 status code and page. | ||
* | ||
* Checks to see if the retrieved page can be resolved by the resolver. If | ||
* not, assumes a 404 code and page. | ||
* | ||
* Otherwise, returns a view model with a template matching the page from | ||
* this module. | ||
* | ||
* @param MvcEvent $e | ||
* @return ViewModel | ||
*/ | ||
public function onDispatch(MvcEvent $e) | ||
{ | ||
$model = new ViewModel(); | ||
$matches = $e->getRouteMatch(); | ||
$page = $matches->getParam('page', false); | ||
|
||
if (!$page) { | ||
return $this->return404Page($model, $e->getResponse()); | ||
} | ||
|
||
$page = 'page-controller/page-controller/' . $page; | ||
if (!$this->resolver->resolve($page)) { | ||
return $this->return404Page($model, $e->getResponse()); | ||
} | ||
|
||
$model->setTemplate($page); | ||
$e->setResult($model); | ||
return $model; | ||
} | ||
|
||
/** | ||
* Return a 404 page and status | ||
* | ||
* @param ViewModel $model | ||
* @param \Zend\Http\Response $response | ||
* @return ViewModel | ||
*/ | ||
protected function return404Page(ViewModel $model, $response) | ||
{ | ||
$model->setTemplate('application/error/404'); | ||
$response->setStatusCode(404); | ||
return $model; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
module/PageController/view/page-controller/page-controller/participate.phtml
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,61 @@ | ||
<?php $this->render('page-controller/page-controller/participate/sidebar') ?> | ||
|
||
<h1>Participate</h1> | ||
|
||
<blockquote> | ||
Zend Framework is a lot more than code. It's a community. | ||
</blockquote> | ||
|
||
<hr/> | ||
|
||
<p> | ||
Zend Framework has hundreds of contributors and our users number in the hundreds of thousands. | ||
We can't thank this vibrant community enough for their many contributions of code, tests, | ||
documentation, and support over the years. | ||
</p> | ||
|
||
<p> | ||
Simply put: we haven't just built a framework together. We've built a community. | ||
</p> | ||
|
||
<h3><a href="/community/guide">Contributors Guide</a></h3> | ||
|
||
<p> | ||
Learn how you can contribute effectively, via our | ||
<a href="/community/guide">contributors guide</a>. | ||
</p> | ||
|
||
<h3><a href="/community/resources">Resources</a></h3> | ||
|
||
<p> | ||
Zend supports the Zend Framework community by providing several useful | ||
<a href="/community/resources">resources</a> | ||
which promote open communication and continuous improvement. | ||
</p> | ||
|
||
<h3><a href="/community/groups">User Groups</a></h3> | ||
|
||
<p> | ||
Want to learn more about Zend Framework? Want to help others learn? Look for a | ||
<a href="/community/groups">user group</a> near you! | ||
</p> | ||
|
||
<h3><a href="/community/blogs">Learn from others</a></h3> | ||
|
||
<p> | ||
Many Zend Framework users are active bloggers, sharing tips and tricks. Get | ||
a taste of what's out there on our <a href="/community/blogs">featured blogs</a> | ||
page. | ||
</p> | ||
|
||
<h3><a href="/community/contributors">Contributors</a></h3> | ||
|
||
<p> | ||
|
||
Zend Framework's contributors have provided guidance, code, documentation, | ||
tests, and support for other community members since the inception of the | ||
project. You'll get a glimpse of a few of our contributors in our | ||
<a href="/community/contributors">contributor gallery</a>. | ||
|
||
</p> | ||
|
10 changes: 10 additions & 0 deletions
10
module/PageController/view/page-controller/page-controller/participate/sidebar.phtml
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,10 @@ | ||
<?php $this->placeholder('sidebar')->captureStart(); ?> | ||
<ul> | ||
<li><a href="/community/guide">Contributors Guide</a></li> | ||
<li><a href="/community/resources">Resources</a></li> | ||
<li><a href="/community/groups">User Groups</a></li> | ||
<li><a href="/community/blogs">Blogs</a></li> | ||
<li><a href="/community/contributors">Contributors</a></li> | ||
</ul> | ||
<?php $this->placeholder('sidebar')->captureEnd(); ?> | ||
|