Skip to content

Instantly share code, notes, and snippets.

@jonathanmaron
Created May 26, 2012 15:20
Show Gist options
  • Save jonathanmaron/2794307 to your computer and use it in GitHub Desktop.
Save jonathanmaron/2794307 to your computer and use it in GitHub Desktop.
<?php
namespace My\View\Helper;
use Zend\View\Helper\AbstractHelper;
class Uri extends AbstractHelper
{
protected $request;
public function __invoke()
{
$uri = new \StdClass();
$uri->relative = $this->getRequest()->getRequestUri();
$uri->absolute = $this->getRequest()->getUri();
$uri->scheme = parse_url($uri->absolute, PHP_URL_SCHEME);
$uri->host = parse_url($uri->absolute, PHP_URL_HOST);
$uri->port = parse_url($uri->absolute, PHP_URL_PORT);
$uri->user = parse_url($uri->absolute, PHP_URL_USER);
$uri->password = parse_url($uri->absolute, PHP_URL_PASS);
$uri->path = parse_url($uri->absolute, PHP_URL_PATH);
$uri->query = parse_url($uri->absolute, PHP_URL_QUERY);
return $uri;
}
public function setRequest($request)
{
$this->request = $request;
}
public function getRequest()
{
return $this->request;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment