当前位置: 首页>>代码示例>>PHP>>正文


PHP NodeInterface::toUrl方法代码示例

本文整理汇总了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);

  }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:49,代码来源:LinkTypeAjaxTest.php

示例2: getCancelUrl

 /**
  * {@inheritdoc}
  */
 public function getCancelUrl()
 {
     return $this->node->toUrl();
 }
开发者ID:Progressable,项目名称:openway8,代码行数:7,代码来源:WebformComponentDeleteForm.php


注:本文中的Drupal\node\NodeInterface::toUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。