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


PHP UserInterface::url方法代码示例

本文整理汇总了PHP中Drupal\user\UserInterface::url方法的典型用法代码示例。如果您正苦于以下问题:PHP UserInterface::url方法的具体用法?PHP UserInterface::url怎么用?PHP UserInterface::url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\user\UserInterface的用法示例。


在下文中一共展示了UserInterface::url方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 protected function setUp()
 {
     parent::setUp();
     // Use Classy theme for testing markup output.
     \Drupal::service('theme_handler')->install(['classy']);
     \Drupal::service('theme_handler')->setDefault('classy');
     $this->baseUri = \Drupal::url('<front>', [], ['absolute' => TRUE]);
     // Create two test users.
     $this->adminUser = $this->drupalCreateUser(array('administer content types', 'administer comments', 'access comments', 'access content'));
     $this->webUser = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval', 'access content'));
     $this->drupalLogin($this->adminUser);
     // Create term.
     $this->term = Term::create(['name' => $this->randomMachineName(), 'description' => $this->randomMachineName(), 'vid' => 'tags']);
     $this->term->save();
     // Create image.
     file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', 'public://example.jpg');
     $this->image = File::create(['uri' => 'public://example.jpg']);
     $this->image->save();
     // Create article.
     $article_settings = array('type' => 'article', 'promote' => NODE_PROMOTED, 'field_image' => array(array('target_id' => $this->image->id())), 'field_tags' => array(array('target_id' => $this->term->id())));
     $this->article = $this->drupalCreateNode($article_settings);
     // Create second article to test teaser list.
     $this->drupalCreateNode(array('type' => 'article', 'promote' => NODE_PROMOTED));
     // Create article comment.
     $this->articleComment = $this->saveComment($this->article->id(), $this->webUser->id(), NULL, 0);
     // Create page.
     $this->page = $this->drupalCreateNode(array('type' => 'page'));
     // Set URIs.
     // Image.
     $image_file = $this->article->get('field_image')->entity;
     $this->imageUri = ImageStyle::load('large')->buildUrl($image_file->getFileUri());
     // Term.
     $this->termUri = $this->term->url('canonical', array('absolute' => TRUE));
     // Article.
     $this->articleUri = $this->article->url('canonical', array('absolute' => TRUE));
     // Page.
     $this->pageUri = $this->page->url('canonical', array('absolute' => TRUE));
     // Author.
     $this->authorUri = $this->adminUser->url('canonical', array('absolute' => TRUE));
     // Comment.
     $this->articleCommentUri = $this->articleComment->url('canonical', array('absolute' => TRUE));
     // Commenter.
     $this->commenterUri = $this->webUser->url('canonical', array('absolute' => TRUE));
     $this->drupalLogout();
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:45,代码来源:StandardProfileTest.php

示例2: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->base_uri = \Drupal::url('<front>', [], ['absolute' => TRUE]);
     // Create two test users.
     $this->adminUser = $this->drupalCreateUser(array('administer content types', 'administer comments', 'access comments', 'access content'));
     $this->webUser = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval', 'access content'));
     $this->drupalLogin($this->adminUser);
     // Create term.
     $this->term = entity_create('taxonomy_term', array('name' => $this->randomMachineName(), 'description' => $this->randomMachineName(), 'vid' => 'tags'));
     $this->term->save();
     // Create image.
     file_unmanaged_copy(DRUPAL_ROOT . '/core/misc/druplicon.png', 'public://example.jpg');
     $this->image = entity_create('file', array('uri' => 'public://example.jpg'));
     $this->image->save();
     // Create article.
     $article_settings = array('type' => 'article', 'promote' => NODE_PROMOTED, 'field_image' => array(array('target_id' => $this->image->id())), 'field_tags' => array(array('target_id' => $this->term->id())));
     $this->article = $this->drupalCreateNode($article_settings);
     // Create second article to test teaser list.
     $this->drupalCreateNode(array('type' => 'article', 'promote' => NODE_PROMOTED));
     // Create article comment.
     $this->articleComment = $this->saveComment($this->article->id(), $this->webUser->id(), NULL, 0);
     // Create page.
     $this->page = $this->drupalCreateNode(array('type' => 'page'));
     // Set URIs.
     // Image.
     $image_file = $this->article->get('field_image')->entity;
     $this->imageUri = entity_load('image_style', 'large')->buildUrl($image_file->getFileUri());
     // Term.
     $this->termUri = $this->term->url('canonical', array('absolute' => TRUE));
     // Article.
     $this->articleUri = $this->article->url('canonical', array('absolute' => TRUE));
     // Page.
     $this->pageUri = $this->page->url('canonical', array('absolute' => TRUE));
     // Author.
     $this->authorUri = $this->adminUser->url('canonical', array('absolute' => TRUE));
     // Comment.
     $this->articleCommentUri = $this->articleComment->url('canonical', array('absolute' => TRUE));
     // Commenter.
     $this->commenterUri = $this->webUser->url('canonical', array('absolute' => TRUE));
     $this->drupalLogout();
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:42,代码来源:StandardProfileTest.php

示例3: url

 /**
  * {@inheritdoc}
  */
 public function url($rel = 'canonical', $options = array())
 {
     return $this->subject->url($rel, $options);
 }
开发者ID:mosswoodcreative,项目名称:d8-api-test,代码行数:7,代码来源:TokenAuthUser.php


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