本文整理匯總了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'));
}
}