本文整理汇总了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();
}
示例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();
}
示例3: url
/**
* {@inheritdoc}
*/
public function url($rel = 'canonical', $options = array())
{
return $this->subject->url($rel, $options);
}