Skip to content
This repository has been archived by the owner on Mar 14, 2019. It is now read-only.

Commit

Permalink
Created PageController module
Browse files Browse the repository at this point in the history
- 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
weierophinney committed Aug 27, 2012
1 parent 0f298e2 commit 5c90c58
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 2 deletions.
1 change: 1 addition & 0 deletions TODO.md
Expand Up @@ -52,6 +52,7 @@ Consolidated Tree
- Links to Github repos
- Links to JIRA, Confluence
- AgileZen board
- Logos
- User Groups
- Blogs
- Contributors
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config/application.config.php
Expand Up @@ -2,6 +2,7 @@
return array(
'modules' => array(
'Application',
'PageController',
),
'module_listener_options' => array(
'config_glob_paths' => array(
Expand Down
22 changes: 22 additions & 0 deletions config/autoload/page-controller.global.php
@@ -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 */
),
),
),
),
),
);
36 changes: 36 additions & 0 deletions module/PageController/Module.php
@@ -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;
},
));
}
}
8 changes: 8 additions & 0 deletions module/PageController/config/module.config.php
@@ -0,0 +1,8 @@
<?php
return array(
'view_manager' => array(
'template_path_stack' => array(
'page-controller' => __DIR__ . '/../view',
),
),
);
@@ -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;
}
}
@@ -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>

@@ -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(); ?>

0 comments on commit 5c90c58

Please sign in to comment.