本文整理汇总了PHP中Drupal\Core\Url::getRouteParameters方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::getRouteParameters方法的具体用法?PHP Url::getRouteParameters怎么用?PHP Url::getRouteParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Url
的用法示例。
在下文中一共展示了Url::getRouteParameters方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRenderAsLinkWithUrlAndOptions
/**
* Tests link rendering with a URL and options.
*
* @dataProvider providerTestRenderAsLinkWithUrlAndOptions
* @covers ::renderAsLink
*/
public function testRenderAsLinkWithUrlAndOptions(Url $url, $alter, Url $expected_url, $url_path, Url $expected_link_url, $link_html, $final_html = NULL)
{
$alter += ['make_link' => TRUE, 'url' => $url];
$final_html = isset($final_html) ? $final_html : $link_html;
$this->setUpUrlIntegrationServices();
$this->setupDisplayWithEmptyArgumentsAndFields();
$field = $this->setupTestField(['alter' => $alter]);
$field->field_alias = 'key';
$row = new ResultRow(['key' => 'value']);
$expected_url->setOptions($expected_url->getOptions() + $this->defaultUrlOptions);
$expected_link_url->setUrlGenerator($this->urlGenerator);
$expected_url_options = $expected_url->getOptions();
unset($expected_url_options['attributes']);
$this->urlGenerator->expects($this->once())->method('generateFromRoute')->with($expected_url->getRouteName(), $expected_url->getRouteParameters(), $expected_url_options)->willReturn($url_path);
$result = $field->advancedRender($row);
$this->assertEquals($final_html, $result);
}
示例2: addGroupParameter
/**
* @param \Drupal\Core\Url $url
* The URL associated with an operation.
*
* @param $migration_group
* The migration's parent group.
*/
protected function addGroupParameter(Url $url, $migration_group)
{
$route_parameters = $url->getRouteParameters() + array('migration_group' => $migration_group);
$url->setRouteParameters($route_parameters);
}
示例3: testGetRouteParameters
/**
* Tests the getRouteParameters() method.
*
* @depends testCreateFromPath
*
* @expectedException \UnexpectedValueException
*
* @covers ::getRouteParameters()
*/
public function testGetRouteParameters(Url $url)
{
$url->getRouteParameters();
}
示例4: addGroupParameter
/**
* @param \Drupal\Core\Url $url
* The URL associated with an operation.
*
* @param $migration_group
* The migration's parent group.
*/
protected function addGroupParameter(Url $url, $migration_group)
{
if (!$migration_group) {
$migration_group = 'default';
}
$route_parameters = $url->getRouteParameters() + ['migration_group' => $migration_group];
$url->setRouteParameters($route_parameters);
}
示例5: assertUrl
/**
* Asserts that a given URL object matches the expectations.
*
* @param string $expected_route_name
* The expected route name of the generated URL.
* @param array $expected_route_parameters
* The expected route parameters of the generated URL.
* @param \Drupal\Core\Entity\Entity|\PHPUnit_Framework_MockObject_MockObject $entity
* The entity that is expected to be set as a URL option.
* @param bool $has_language
* Whether or not the URL is expected to have a language option.
* @param \Drupal\Core\Url $url
* The URL option to make the assertions on.
*/
protected function assertUrl($expected_route_name, array $expected_route_parameters, $entity, $has_language, Url $url)
{
$this->assertEquals($expected_route_name, $url->getRouteName());
$this->assertEquals($expected_route_parameters, $url->getRouteParameters());
$this->assertEquals($this->entityTypeId, $url->getOption('entity_type'));
$this->assertEquals($entity, $url->getOption('entity'));
if ($has_language) {
$this->assertEquals($this->langcode, $url->getOption('language')->getId());
} else {
$this->assertNull($url->getOption('language'));
}
}