for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @author Gerard van Helden <[email protected]>
* @copyright Zicht Online <http://zicht.nl>
*/
namespace Zicht\Bundle\UrlBundle\Url;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
* Static provider holds a set of urls
class StaticProvider implements Provider
{
* Create the provider with a set of static references, i.e. mappings from name to url.
*
* @param \Symfony\Component\Routing\RouterInterface $router
* @param array $refs
public function __construct(RouterInterface $router, array $refs = array())
$this->refs = $refs;
refs
$this->router = $router;
router
}
* Add the array as references
* @return void
public function addAll(array $refs)
$this->refs = $refs + $this->refs;
* Add a single reference
* @param string $name
* @param string $value
public function add($name, $value)
$this->refs[$name] = $value;
* @{inheritDoc}
public function supports($object)
return is_string($object) && isset($this->refs[$object]);
public function url($object, array $options = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
return $this->router->getContext()->getBaseUrl() . '/' . ltrim($this->refs[$object], '/');