Skip to content

Instantly share code, notes, and snippets.

@davidwindell
Created June 22, 2012 13:40
Show Gist options
  • Save davidwindell/2972789 to your computer and use it in GitHub Desktop.
Save davidwindell/2972789 to your computer and use it in GitHub Desktop.
<?php
namespace Application\Mvc\Router\Http;
use Zend\Mvc\Router\Http\Hostname as HttpHostname;
use Zend\Stdlib\RequestInterface as Request;
use Zend\Mvc\Router\Http\RouteMatch;
use Zend\ServiceManager\ServiceManagerAwareInterface;
use Zend\ServiceManager\ServiceManager;
class Hostname extends HttpHostname implements ServiceManagerAwareInterface {
/**
* @var \Zend\ServiceManager\ServiceManager
*/
protected $serviceManager;
public function match(Request $request) {
/* @var $account \Application\Entity\Account */
$account = $this->serviceManager->get('Application\Service\Account')->getFromUri($request->uri()->getHost());
if (!$account) {
return null;
}
return new RouteMatch(array('account' => $account));
}
/**
* @param ServiceManager $serviceManager
* @return Service
*/
public function setServiceManager(ServiceManager $serviceManager) {
$this->serviceManager = $serviceManager;
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment