本文整理汇总了PHP中Drupal\node\NodeInterface::toUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::toUrl方法的具体用法?PHP NodeInterface::toUrl怎么用?PHP NodeInterface::toUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\node\NodeInterface
的用法示例。
在下文中一共展示了NodeInterface::toUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doUseAjaxFlag
/**
* Test an AJAX flag link.
*/
public function doUseAjaxFlag() {
// Create and login as an authenticated user.
$auth_user = $this->drupalCreateUser();
$this->drupalLogin($auth_user);
$node_url = $this->node->toUrl();
// Navigate to the node page.
$this->drupalGet($node_url);
// Confirm the flag link exists.
$this->assertLink($this->flag->getFlagShortText());
// Click the flag link. This ensures that the non-JS fallback works we are
// redirected to back to the page and the node is flagged.
$this->clickLink($this->flag->getFlagShortText());
$this->assertUrl($node_url);
$this->assertLink($this->flag->getUnflagShortText());
// Click the unflag link, repeat the check.
$this->clickLink($this->flag->getUnflagShortText());
$this->assertUrl($node_url);
$this->assertLink($this->flag->getFlagShortText());
// Now also test with an ajax request and that the correct response is
// returned. Use the same logic as clickLink() to find the link.
$urls = $this->xpath('//a[normalize-space()=:label]', array(':label' => $this->flag->getFlagShortText()));
$url_target = $this->getAbsoluteUrl($urls[0]['href']);
$ajax_response = $this->drupalGetAjax($url_target);
// Assert that the replace selector is correct.
$this->assertEqual($ajax_response[0]['selector'], '#' .$urls[0]['id']);
// Request the returned URL to ensure that link is valid and has a valid
// CSRF token.
$xml_data = new \SimpleXMLElement($ajax_response[0]['data']);
$this->assertEqual($this->flag->getUnflagShortText(), (string) $xml_data);
$ajax_response = $this->drupalGetAjax($this->getAbsoluteUrl($xml_data['href']));
// Assert that the replace selector is correct.
$this->assertEqual($ajax_response[0]['selector'], '#' . $xml_data['id']);
$xml_data_unflag = new \SimpleXMLElement($ajax_response[0]['data']);
$this->assertEqual($this->flag->getFlagShortText(), (string) $xml_data_unflag);
}
示例2: getCancelUrl
/**
* {@inheritdoc}
*/
public function getCancelUrl()
{
return $this->node->toUrl();
}