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