Created
June 22, 2012 13:40
-
-
Save davidwindell/2972789 to your computer and use it in GitHub Desktop.
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
<?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