本文整理汇总了PHP中Zend\Mvc\Router\Http\TreeRouteStack::assemble方法的典型用法代码示例。如果您正苦于以下问题:PHP TreeRouteStack::assemble方法的具体用法?PHP TreeRouteStack::assemble怎么用?PHP TreeRouteStack::assemble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mvc\Router\Http\TreeRouteStack
的用法示例。
在下文中一共展示了TreeRouteStack::assemble方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateUri
/**
* {@inheritDoc}
*/
public function generateUri($name, array $substitutions = [])
{
if (!$this->zf2Router->hasRoute($name)) {
throw new Exception\RuntimeException(sprintf('Cannot generate URI based on route "%s"; route not found', $name));
}
$name = isset($this->routeNameMap[$name]) ? $this->routeNameMap[$name] : $name;
$options = ['name' => $name, 'only_return_path' => true];
return $this->zf2Router->assemble($substitutions, $options);
}
示例2: assemble
/**
* assemble(): defined by \Zend\Mvc\Router\RouteInterface interface.
*
* @see \Zend\Mvc\Router\RouteInterface::assemble()
* @param array $params
* @param array $options
* @return mixed
* @throws Exception\InvalidArgumentException
* @throws Exception\RuntimeException
*/
public function assemble(array $params = array(), array $options = array())
{
if ($this->hasTranslator() && $this->isTranslatorEnabled() && !isset($options['translator'])) {
$options['translator'] = $this->getTranslator();
}
if (!isset($options['text_domain'])) {
$options['text_domain'] = $this->getTranslatorTextDomain();
}
return parent::assemble($params, $options);
}
示例3: assemble
/**
* (non-PHPdoc)
*
* @see \Zend\Mvc\Router\Http\TreeRouteStack::assemble()
*/
public function assemble(array $params = [], array $options = [])
{
// Generate orignal URL
$url = parent::assemble($params, $options);
// Fill Route-Map
if (null === $this->routeMap) {
$this->routeMap = [];
$nodes = $this->getServiceLocator()->get('NodeService')->getNodes();
foreach ($nodes as $node) {
if (false == empty($node->getNodeOriginalRoute()) && 'redirect' != $node->getNodeType()) {
$this->routeMap[$node->getNodeOriginalRoute()] = $node->getNodeRoute();
}
}
}
// Get URL from Route-Map and return it
if (true === isset($this->routeMap[$url])) {
return $this->routeMap[$url];
}
// Return original URL
return $url;
}
示例4: testDefaultParamDoesNotOverrideParamForAssembling
public function testDefaultParamDoesNotOverrideParamForAssembling()
{
$stack = new TreeRouteStack();
$stack->addRoute('foo', new TestAsset\DummyRouteWithParam());
$stack->setDefaultParam('foo', 'baz');
$this->assertEquals('bar', $stack->assemble(array('foo' => 'bar'), array('name' => 'foo')));
}
示例5: assemble
/**
* assemble(): Defined by RouteInterface interface.
*
* @see Route::assemble()
* @param array $params
* @param array $options
* @return mixed
* @throws Exception\RuntimeException
*/
public function assemble(array $params = array(), array $options = array())
{
if ($this->childRoutes !== null) {
$this->addRoutes($this->childRoutes);
$this->childRoutes = null;
}
$options['has_child'] = isset($options['name']);
$path = $this->route->assemble($params, $options);
$params = array_diff_key($params, array_flip($this->route->getAssembledParams()));
if (!isset($options['name'])) {
if (!$this->mayTerminate) {
throw new Exception\RuntimeException('Part route may not terminate');
} else {
return $path;
}
}
unset($options['has_child']);
$options['only_return_path'] = true;
$path .= parent::assemble($params, $options);
return $path;
}
示例6: assemble
/**
* assemble(): Defined by Route interface.
*
* @see Route::assemble()
* @param array $params
* @param array $options
* @return mixed
*/
public function assemble(array $params = null, array $options = null)
{
if ($this->childRoutes !== null) {
$this->addRoutes($this->childRoutes);
$this->childRoutes = null;
}
$uri = $this->route->assemble($params, $options)
. parent::assemble($params, $options);
return $uri;
}
示例7: assemble
/**
* assemble(): Defined by Route interface.
*
* @see Route::assemble()
* @param array $params
* @param array $options
* @return mixed
*/
public function assemble(array $params = array(), array $options = array())
{
if ($this->childRoutes !== null) {
$this->addRoutes($this->childRoutes);
$this->childRoutes = null;
}
$uri = $this->route->assemble($params, $options);
if (!isset($options['name'])) {
if (!$this->mayTerminate) {
throw new Exception\RuntimeException('Part route may not terminate');
} else {
return $uri;
}
}
$uri .= parent::assemble($params, $options);
return $uri;
}
示例8: testChainRouteAssembling
public function testChainRouteAssembling()
{
$stack = new TreeRouteStack();
$stack->addPrototype('bar', array('type' => 'literal', 'options' => array('route' => '/bar')));
$stack->addRoute('foo', array('type' => 'literal', 'options' => array('route' => '/foo'), 'chain_routes' => array('bar')));
$this->assertEquals('/foo/bar', $stack->assemble(array(), array('name' => 'foo')));
}
示例9: getUploadUrl
/**
* Get upload url path
*
* @param integer $propertyId Property id
*
* @return string
*/
public function getUploadUrl($propertyId)
{
return $this->router->assemble(array('document_id' => $this->getDocumentId(), 'property_id' => $propertyId), array('name' => 'content/media/upload'));
}
示例10: testChainRouteAssemblingWithChildrenAndSecureScheme
public function testChainRouteAssemblingWithChildrenAndSecureScheme()
{
$stack = new TreeRouteStack();
$uri = new \Zend\Uri\Http();
$uri->setHost('localhost');
$stack->setRequestUri($uri);
$stack->addRoute('foo', array('type' => 'literal', 'options' => array('route' => '/foo'), 'chain_routes' => array(array('type' => 'scheme', 'options' => array('scheme' => 'https'))), 'child_routes' => array('baz' => array('type' => 'literal', 'options' => array('route' => '/baz')))));
$this->assertEquals('https://localhost/foo/baz', $stack->assemble(array(), array('name' => 'foo/baz')));
}