Commit 0eda196d authored by webchick's avatar webchick

Issue #2340251 by iMiksu, alexpott, tim.plunkett, dawehner, Wim Leers: Remove...

Issue #2340251 by iMiksu, alexpott, tim.plunkett, dawehner, Wim Leers: Remove most remaining url() calls.
parent 8bd63769
......@@ -456,9 +456,11 @@ services:
tags:
- { name: backend_overridable }
router.request_context:
class: Symfony\Component\Routing\RequestContext
class: Drupal\Core\Routing\RequestContext
tags:
- { name: persist }
calls:
- [fromRequestStack, ['@request_stack']]
router.admin_context:
class: Drupal\Core\Routing\AdminContext
arguments: ['@request_stack']
......
......@@ -45,7 +45,7 @@ function _batch_page(Request $request) {
$batch = \Drupal::service('batch.storage')->load($request_id);
if (!$batch) {
drupal_set_message(t('No active batch.'), 'error');
return new RedirectResponse(url('<front>', array('absolute' => TRUE)));
return new RedirectResponse(\Drupal::url('<front>', [], ['absolute' => TRUE]));
}
}
// Restore safe strings from previous batches.
......
......@@ -677,7 +677,7 @@ function drupal_http_header_attributes(array $attributes = array()) {
* However, for links enclosed in translatable text you should use t() and
* embed the HTML anchor tag directly in the translated string. For example:
* @code
* t('Visit the <a href="@url">settings</a> page', array('@url' => url('admin')));
* t('Visit the <a href="@url">settings</a> page', array('@url' => \Drupal::url('system.admin')));
* @endcode
* This keeps the context of the link title ('settings' in the example) for
* translators.
......
......@@ -647,8 +647,9 @@ function drupal_install_system($install_state) {
// Install base system configuration.
\Drupal::service('config.installer')->installDefaultConfig('core', 'core');
// Install System module.
// Install System module and rebuild the newly available routes.
$kernel->getContainer()->get('module_handler')->install(array('system'), FALSE);
\Drupal::service('router.builder')->rebuild();
// DrupalKernel::prepareLegacyRequest() above calls into
// DrupalKernel::bootCode(), which primes file_get_stream_wrappers()'s static
......
......@@ -1797,7 +1797,7 @@ function template_preprocess_page(&$variables) {
}
$variables['base_path'] = base_path();
$variables['front_page'] = url();
$variables['front_page'] = \Drupal::url('<front>');
$variables['language'] = $language_interface;
$variables['language']->dir = $language_interface->direction ? 'rtl' : 'ltr';
$variables['logo'] = theme_get_setting('logo.url');
......
......@@ -339,8 +339,8 @@ public function calculateDependencies() {
/**
* {@inheritdoc}
*/
public function urlInfo($rel = 'edit-form') {
return parent::urlInfo($rel);
public function urlInfo($rel = 'edit-form', array $options = []) {
return parent::urlInfo($rel, $options);
}
/**
......
......@@ -146,7 +146,7 @@ public function label() {
/**
* {@inheritdoc}
*/
public function urlInfo($rel = 'canonical') {
public function urlInfo($rel = 'canonical', array $options = []) {
if ($this->isNew()) {
throw new EntityMalformedException(sprintf('The "%s" entity type has not been saved, and cannot have a URI.', $this->getEntityTypeId()));
}
......@@ -188,8 +188,9 @@ public function urlInfo($rel = 'canonical') {
$uri
->setOption('entity_type', $this->getEntityTypeId())
->setOption('entity', $this);
return $uri;
$uri_options = $uri->getOptions();
$uri_options += $options;
return $uri->setOptions($uri_options);
}
/**
......
......@@ -119,10 +119,13 @@ public function label();
*
* @param string $rel
* The link relationship type, for example: canonical or edit-form.
* @param array $options
* See \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute() for
* the available options.
*
* @return \Drupal\Core\Url
*/
public function urlInfo($rel = 'canonical');
public function urlInfo($rel = 'canonical', array $options = array());
/**
* Returns the public URL for this entity.
......
......@@ -12,7 +12,7 @@
use Symfony\Cmf\Component\Routing\ChainRouter;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RequestContext as SymfonyRequestContext;
/**
* A router class for Drupal with access check and upcasting.
......@@ -68,7 +68,7 @@ public function __call($name, $arguments) {
/**
* {@inheritdoc}
*/
public function setContext(RequestContext $context) {
public function setContext(SymfonyRequestContext $context) {
$this->chainRouter->setContext($context);
}
......
......@@ -8,7 +8,7 @@
namespace Drupal\Core\Routing;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RequestContext as SymfonyRequestContext;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\Route;
......@@ -25,6 +25,7 @@ class NullGenerator extends UrlGenerator {
*/
public function __construct(RequestStack $request_stack) {
$this->requestStack = $request_stack;
$this->context = new RequestContext();
}
/**
......@@ -34,13 +35,29 @@ public function __construct(RequestStack $request_stack) {
* protected method.
*/
protected function getRoute($name) {
if ($name === '<front>') {
return new Route('/');
}
throw new RouteNotFoundException();
}
/**
* {@inheritdoc}
*/
protected function processRoute(Route $route, array &$parameters) {
}
/**
* {@inheritdoc}
*/
protected function getInternalPathFromRoute(Route $route, $parameters = array()) {
return $route->getPath();
}
/**
* Overrides Drupal\Core\Routing\UrlGenerator::setContext();
*/
public function setContext(RequestContext $context) {
public function setContext(SymfonyRequestContext $context) {
}
/**
......
<?php
/**
* @file
* Contains \Drupal\Core\Routing\RequestContext.
*/
namespace Drupal\Core\Routing;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\RequestContext as SymfonyRequestContext;
/**
* Holds information about the current request.
*
* @todo: Remove once the upstream RequestContext provides fromRequestStack():
* https://github.com/symfony/symfony/issues/12057
*/
class RequestContext extends SymfonyRequestContext {
/**
* Populates the context from the current request from the request stack.
*
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
*/
public function fromRequestStack(RequestStack $request_stack) {
$this->fromRequest($request_stack->getCurrentRequest());
}
}
......@@ -55,6 +55,18 @@ class UrlGenerator extends ProviderBasedGenerator implements UrlGeneratorInterfa
*/
protected $mixedModeSessions;
/**
* Overrides characters that will not be percent-encoded in the path segment.
*
* @see \Symfony\Component\Routing\Generator\UrlGenerator
*/
protected $decodedChars = array(
// the slash can be used to designate a hierarchical structure and we want allow using it with this meaning
// some webservers don't allow the slash in encoded form in the path for security reasons anyway
// see http://stackoverflow.com/questions/4069002/http-400-if-2f-part-of-get-url-in-jboss
'%2F' => '/',
);
/**
* Constructs a new generator object.
*
......
......@@ -9,7 +9,6 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RequestContext;
use Symfony\Cmf\Component\Routing\NestedMatcher\UrlMatcher as BaseUrlMatcher;
/**
......
......@@ -7,6 +7,8 @@
namespace Drupal\Core\StreamWrapper;
use Drupal\Core\Routing\UrlGeneratorTrait;
/**
* Drupal private (private://) stream wrapper class.
*
......@@ -15,6 +17,8 @@
*/
class PrivateStream extends LocalStream {
use UrlGeneratorTrait;
/**
* Implements Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath()
*/
......@@ -30,6 +34,6 @@ public function getDirectoryPath() {
*/
function getExternalUrl() {
$path = str_replace('\\', '/', $this->getTarget());
return url('system/files/' . $path, array('absolute' => TRUE));
return $this->url('system.private_file_download', ['filepath' => $path], ['absolute' => TRUE]);
}
}
......@@ -27,6 +27,6 @@ public function getDirectoryPath() {
*/
public function getExternalUrl() {
$path = str_replace('\\', '/', $this->getTarget());
return url('system/temporary/' . $path, array('absolute' => TRUE));
return $this->url('system.temporary', ['scheme' => $path], ['absolute' => TRUE]);
}
}
......@@ -172,7 +172,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['refresh'] = BaseFieldDefinition::create('list_integer')
->setLabel(t('Update interval'))
->setDescription(t('The length of time between feed updates. Requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))))
->setDescription(t('The length of time between feed updates. Requires a correctly configured cron maintenance task.'))
->setSetting('unsigned', TRUE)
->setRequired(TRUE)
->setSetting('allowed_values', $period)
......
......@@ -17,6 +17,7 @@
use Drupal\Core\Entity\Query\QueryInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Routing\UrlGeneratorTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -32,6 +33,8 @@
*/
class DefaultProcessor extends AggregatorPluginSettingsBase implements ProcessorInterface, ContainerFactoryPluginInterface {
use UrlGeneratorTrait;
/**
* Contains the configuration object factory.
*
......@@ -141,7 +144,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
'#title' => t('Discard items older than'),
'#default_value' => $this->configuration['items']['expire'],
'#options' => $period,
'#description' => t('Requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))),
'#description' => t('Requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => $this->url('system.status'))),
);
$lengths = array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000);
......
......@@ -20,7 +20,7 @@ function testAddFeed() {
$feed = $this->createFeed();
// Check feed data.
$this->assertEqual($this->getUrl(), url('aggregator/sources/add', array('absolute' => TRUE)), 'Directed to correct url.');
$this->assertUrl(\Drupal::url('aggregator.feed_add', [], ['absolute' => TRUE]), [], 'Directed to correct url.');
$this->assertTrue($this->uniqueFeed($feed->label(), $feed->getUrl()), 'The feed is unique.');
// Check feed source.
......
......@@ -53,8 +53,8 @@ public function testBlockLinks() {
$this->assertText($block->label(), 'Feed block is displayed on the page.');
// Find the expected read_more link.
$href = 'aggregator/sources/' . $feed->id();
$links = $this->xpath('//a[@href = :href]', array(':href' => url($href)));
$href = $feed->url();
$links = $this->xpath('//a[@href = :href]', array(':href' => $href));
$this->assert(isset($links[0]), format_string('Link to href %href found.', array('%href' => $href)));
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
$cache_tags = explode(' ', $cache_tags_header);
......@@ -62,7 +62,7 @@ public function testBlockLinks() {
$this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
// Visit that page.
$this->drupalGet($href);
$this->drupalGet($feed->urlInfo()->getInternalPath());
$correct_titles = $this->xpath('//h1[normalize-space(text())=:title]', array(':title' => $feed->label()));
$this->assertFalse(empty($correct_titles), 'Aggregator feed page is available and has the correct title.');
$cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags'));
......@@ -106,8 +106,8 @@ public function testFeedPage() {
$this->assertTrue(!empty($titles), 'Source page contains correct title.');
// Find the expected read_more link on the sources page.
$href = 'aggregator/sources/' . $feed->id();
$links = $this->xpath('//a[@href = :href]', array(':href' => url($href)));
$href = $feed->url();
$links = $this->xpath('//a[@href = :href]', array(':href' => $href));
$this->assertTrue(isset($links[0]), String::format('Link to href %href found.', array('%href' => $href)));
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
$cache_tags = explode(' ', $cache_tags_header);
......
......@@ -87,7 +87,7 @@ function deleteFeed(FeedInterface $feed) {
function getFeedEditArray($feed_url = NULL, array $edit = array()) {
$feed_name = $this->randomMachineName(10);
if (!$feed_url) {
$feed_url = url('rss.xml', array(
$feed_url = \Drupal::url('view.frontpage.feed_1', array(), array(
'query' => array('feed' => $feed_name),
'absolute' => TRUE,
));
......@@ -115,7 +115,7 @@ function getFeedEditArray($feed_url = NULL, array $edit = array()) {
function getFeedEditObject($feed_url = NULL, array $values = array()) {
$feed_name = $this->randomMachineName(10);
if (!$feed_url) {
$feed_url = url('rss.xml', array(
$feed_url = \Drupal::url('view.frontpage.feed_1', array(
'query' => array('feed' => $feed_name),
'absolute' => TRUE,
));
......
......@@ -20,13 +20,13 @@ function testDeleteFeedItem() {
// Create a bunch of test feeds.
$feed_urls = array();
// No last-modified, no etag.
$feed_urls[] = url('aggregator/test-feed', array('absolute' => TRUE));
$feed_urls[] = \Drupal::url('aggregator_test.feed', array(), array('absolute' => TRUE));
// Last-modified, but no etag.
$feed_urls[] = url('aggregator/test-feed/1', array('absolute' => TRUE));
$feed_urls[] = \Drupal::url('aggregator_test.feed', array('use_last_modified' => 1), array('absolute' => TRUE));
// No Last-modified, but etag.
$feed_urls[] = url('aggregator/test-feed/0/1', array('absolute' => TRUE));
$feed_urls[] = \Drupal::url('aggregator_test.feed', array('use_last_modified' => 0, 'use_etag' => 1), array('absolute' => TRUE));
// Last-modified and etag.
$feed_urls[] = url('aggregator/test-feed/1/1', array('absolute' => TRUE));
$feed_urls[] = \Drupal::url('aggregator_test.feed', array('use_last_modified' => 1, 'use_etag' => 1), array('absolute' => TRUE));
foreach ($feed_urls as $feed_url) {
$feed = $this->createFeed($feed_url);
......
......@@ -86,7 +86,7 @@ function testRedirectFeed() {
$feed->refreshItems();
// Make sure that the feed URL was updated correctly.
$this->assertEqual($feed->getUrl(), url('aggregator/test-feed', array('absolute' => TRUE)));
$this->assertEqual($feed->getUrl(), \Drupal::url('aggregator_test.feed', array(), array('absolute' => TRUE)));
}
/**
......
......@@ -31,7 +31,7 @@ function testUpdateFeed() {
$this->assertRaw(t('The feed %name has been updated.', array('%name' => $edit['title[0][value]'])), format_string('The feed %name has been updated.', array('%name' => $edit['title[0][value]'])));
// Check feed data.
$this->assertEqual($this->getUrl(), url('aggregator/sources/' . $feed->id(), array('absolute' => TRUE)));
$this->assertUrl($feed->url('canonical', ['absolute' => TRUE]));
$this->assertTrue($this->uniqueFeed($edit['title[0][value]'], $edit['url[0][value]']), 'The feed is unique.');
// Check feed source.
......
......@@ -289,7 +289,7 @@ public function testBlockCacheTags() {
// both the page and block caches.
$this->drupalGet('<front>');
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
$cid_parts = array(url('<front>', array('absolute' => TRUE)), 'html');
$cid_parts = array(\Drupal::url('<front>', array(), array('absolute' => TRUE)), 'html');
$cid = sha1(implode(':', $cid_parts));
$cache_entry = \Drupal::cache('render')->get($cid);
$expected_cache_tags = array(
......@@ -331,7 +331,7 @@ public function testBlockCacheTags() {
// Verify a cache hit, but also the presence of the correct cache tags.
$this->drupalGet('<front>');
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT');
$cid_parts = array(url('<front>', array('absolute' => TRUE)), 'html');
$cid_parts = array(\Drupal::url('<front>', array(), array('absolute' => TRUE)), 'html');
$cid = sha1(implode(':', $cid_parts));
$cache_entry = \Drupal::cache('render')->get($cid);
$expected_cache_tags = array(
......
......@@ -87,7 +87,7 @@ public function testBlockContentTypeEditing() {
$this->drupalGet('block/add');
$this->assertRaw('Bar', 'New name was displayed.');
$this->clickLink('Bar');
$this->assertEqual(url('block/add/basic', array('absolute' => TRUE)), $this->getUrl(), 'Original machine name was used in URL.');
$this->assertUrl(\Drupal::url('block_content.add_form', ['block_content_type' => 'basic'], ['absolute' => TRUE]), [], 'Original machine name was used in URL.');
// Remove the body field.
$this->drupalPostForm('admin/structure/block/block-content/manage/basic/fields/block_content.basic.body/delete', array(), t('Delete'));
......@@ -162,7 +162,7 @@ public function testsBlockContentAddTypes() {
// The seven theme has markup inside the link, we cannot use clickLink().
if ($default_theme == 'seven') {
$options = $theme != $default_theme ? array('query' => array('theme' => $theme)) : array();
$this->assertLinkByHref(url('block/add/foo', $options));
$this->assertLinkByHref(\Drupal::url('block_content.add_form', array('block_content_type' => 'foo'), $options));
$this->drupalGet('block/add/foo', $options);
}
else {
......@@ -174,10 +174,9 @@ public function testsBlockContentAddTypes() {
$blocks = $storage->loadByProperties(array('info' => $edit['info[0][value]']));
if (!empty($blocks)) {
$block = reset($blocks);
$destination = 'admin/structure/block/add/block_content:' . $block->uuid() . '/' . $theme;
$this->assertUrl(url($destination, array('absolute' => TRUE)));
$this->assertUrl(\Drupal::url('block.admin_add', array('plugin_id' => 'block_content:' . $block->uuid(), 'theme' => $theme), array('absolute' => TRUE)));
$this->drupalPostForm(NULL, array(), t('Save block'));
$this->assertUrl(url("admin/structure/block/list/$theme", array('absolute' => TRUE, 'query' => array('block-placement' => drupal_html_class($edit['info[0][value]'])))));
$this->assertUrl(\Drupal::url('block.admin_display_theme', array('theme' => $theme), array('absolute' => TRUE, 'query' => array('block-placement' => drupal_html_class($edit['info[0][value]'])))));
}
else {
$this->fail('Could not load created block.');
......@@ -194,8 +193,7 @@ public function testsBlockContentAddTypes() {
$this->drupalPostForm(NULL, $edit, t('Save'));
$blocks = $storage->loadByProperties(array('info' => $edit['info[0][value]']));
if (!empty($blocks)) {
$destination = 'admin/structure/block/block-content';
$this->assertUrl(url($destination, array('absolute' => TRUE)));
$this->assertUrl(\Drupal::url('block_content.list', array(), array('absolute' => TRUE)));
}
else {
$this->fail('Could not load created block.');
......
......@@ -200,9 +200,9 @@ function checkBookNode(EntityInterface $node, $nodes, $previous = FALSE, $up = F
// Compute the expected breadcrumb.
$expected_breadcrumb = array();
$expected_breadcrumb[] = url('');
$expected_breadcrumb[] = \Drupal::url('<front>');
foreach ($breadcrumb as $a_node) {
$expected_breadcrumb[] = url('node/' . $a_node->id());
$expected_breadcrumb[] = $a_node->url();
}
// Fetch links in the current breadcrumb.
......
......@@ -165,12 +165,12 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
// Comment related URLs.
case 'url':
$url_options['fragment'] = 'comment-' . $comment->id();
$replacements[$original] = url('comment/' . $comment->id(), $url_options);
$replacements[$original] = $comment->url('canonical', $url_options);
break;
case 'edit-url':
$url_options['fragment'] = NULL;
$replacements[$original] = url('comment/' . $comment->id() . '/edit', $url_options);
$replacements[$original] = $comment->url('edit-form', $url_options);
break;
// @todo Remove 'name' token in favour of 'author'. See
......
......@@ -95,7 +95,7 @@ public function form(array $form, FormStateInterface $form_state) {
// If not replying to a comment, use our dedicated page callback for new
// Comments on entities.
if (!$comment->id() && !$comment->hasParentComment()) {
$form['#action'] = url('comment/reply/' . $entity->getEntityTypeId() . '/' . $entity->id() . '/' . $field_name);
$form['#action'] = $this->url('comment.reply', array('entity_type' => $entity->getEntityTypeId(), 'entity' => $entity->id(), 'field_name' => $field_name));
}
$comment_preview = $form_state->get('comment_preview');
......
......@@ -99,7 +99,7 @@ function testCommentInterface() {
// \Drupal\comment\Controller\CommentController::redirectNode().
$this->drupalGet('comment/' . $this->node->id() . '/reply');
// Verify we were correctly redirected.
$this->assertUrl(url('comment/reply/node/' . $this->node->id() . '/comment', array('absolute' => TRUE)));
$this->assertUrl(\Drupal::url('comment.reply', array('entity_type' => 'node', 'entity' => $this->node->id(), 'field_name' => 'comment'), array('absolute' => TRUE)));
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $comment->id());
$this->assertText($subject_text, 'Individual comment-reply subject found.');
$this->assertText($comment_text, 'Individual comment-reply body found.');
......
......@@ -55,7 +55,7 @@ protected function renderNewCommentsNodeLinks(array $node_ids) {
// Perform HTTP request.
return $this->curlExec(array(
CURLOPT_URL => url('comments/render_new_comments_node_links', array('absolute' => TRUE)),
CURLOPT_URL => \Drupal::url('comment.new_comments_node_links', array(), array('absolute' => TRUE)),
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => $post,
CURLOPT_HTTPHEADER => array(
......@@ -114,7 +114,7 @@ public function testCommentNewCommentsIndicator() {
$json = Json::decode($response);
$expected = array($this->node->id() => array(
'new_comment_count' => 1,
'first_new_comment_link' => url('node/' . $this->node->id(), array('fragment' => 'new')),
'first_new_comment_link' => $this->node->url('canonical', array('fragment' => 'new')),
));
$this->assertIdentical($expected, $json);
......
......@@ -31,7 +31,7 @@ function testCommentRss() {
$this->drupalLogin($this->web_user);
$this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName());
$this->drupalGet('rss.xml');
$raw = '<comments>' . url('node/' . $this->node->id(), array('fragment' => 'comments', 'absolute' => TRUE)) . '</comments>';
$raw = '<comments>' . $this->node->url('canonical', array('fragment' => 'comments', 'absolute' => TRUE)) . '</comments>';
$this->assertRaw($raw, 'Comments as part of RSS feed.');
// Hide comments from RSS feed and check presence.
......
......@@ -57,8 +57,8 @@ function testCommentTokenReplacement() {
$tests['[comment:homepage]'] = check_url($comment->getHomepage());
$tests['[comment:title]'] = Xss::filter($comment->getSubject());
$tests['[comment:body]'] = $comment->comment_body->processed;
$tests['[comment:url]'] = url('comment/' . $comment->id(), $url_options + array('fragment' => 'comment-' . $comment->id()));
$tests['[comment:edit-url]'] = url('comment/' . $comment->id() . '/edit', $url_options);
$tests['[comment:url]'] = $comment->url('canonical', $url_options + array('fragment' => 'comment-' . $comment->id()));
$tests['[comment:edit-url]'] = $comment->url('edit-form', $url_options);
$tests['[comment:created:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $comment->getCreatedTime(), 2, $language_interface->id);
$tests['[comment:changed:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $comment->getChangedTime(), 2, $language_interface->id);
$tests['[comment:parent:cid]'] = $comment->hasParentComment() ? $comment->getParentComment()->id() : NULL;
......
......@@ -108,7 +108,7 @@ public function testCommentTypeEditing() {
$this->drupalGet('admin/structure/comment');
$this->assertRaw('Bar', 'New name was displayed.');
$this->clickLink('Manage fields');
$this->assertEqual(url('admin/structure/comment/manage/comment/fields', array('absolute' => TRUE)), $this->getUrl(), 'Original machine name was used in URL.');
$this->assertUrl(\Drupal::url('field_ui.overview_comment', array('comment_type' => 'comment'), array('absolute' => TRUE)), [], 'Original machine name was used in URL.');
// Remove the body field.
$this->drupalPostForm('admin/structure/comment/manage/comment/fields/comment.comment.comment_body/delete', array(), t('Delete'));
......
......@@ -41,7 +41,7 @@ public function editTitle(ConfigTest $config_test) {
*/
function enable(ConfigTest $config_test) {
$config_test->enable()->save();
return new RedirectResponse(url('admin/structure/config_test', array('absolute' => TRUE)));
return new RedirectResponse($this->url('config_test.list_page', array(), array('absolute' => TRUE)));
}
/**
......@@ -55,7 +55,7 @@ function enable(ConfigTest $config_test) {
*/
function disable(ConfigTest $config_test) {
$config_test->disable()->save();
return new RedirectResponse(url('admin/structure/config_test', array('absolute' => TRUE)));
return new RedirectResponse(\Drupal::url('config_test.list_page', array(), array('absolute' => TRUE)));
}
}
......@@ -22,18 +22,18 @@ function contact_help($route_name, RouteMatchInterface $route_match) {
$output .= '<dt>' . t('User contact forms') . '</dt>';
$output .= '<dd>' . t('Site users can be contacted with a user contact form that keeps their email address private. Users may enable or disable their personal contact forms by editing their <em>My account</em> page. If enabled, a <em>Contact</em> tab leads to a personal contact form displayed on their user profile. Site administrators are still able to use the contact form, even if has been disabled. The <em>Contact</em> tab is not shown when you view your own profile.') . '</dd>';
$output .= '<dt>' . t('Site-wide contact forms') . '</dt>';
$output .= '<dd>' . t('The <a href="@contact">Contact page</a> provides a simple form for users with the <em>Use the site-wide contact form</em> permission to send comments, feedback, or other requests. You can create forms for directing the contact messages to a set of defined recipients. Common forms for a business site, for example, might include "Website feedback" (messages are forwarded to website administrators) and "Product information" (messages are forwarded to members of the sales department). Email addresses defined within a form are not displayed publicly.', array('@contact' => url('contact'))) . '</p>';
$output .= '<dd>' . t('The <a href="@contact">Contact page</a> provides a simple form for users with the <em>Use the site-wide contact form</em> permission to send comments, feedback, or other requests. You can create forms for directing the contact messages to a set of defined recipients. Common forms for a business site, for example, might include "Website feedback" (messages are forwarded to website administrators) and "Product information" (messages are forwarded to members of the sales department). Email addresses defined within a form are not displayed publicly.', array('@contact' => \Drupal::url('contact.site_page'))) . '</p>';
$output .= '<dt>' . t('Navigation') . '</dt>';
$output .= '<dd>' . t('When the site-wide contact form is enabled, a link in the <em>Footer</em> menu is created, which you can modify on the <a href="@menu">Menus administration page</a>.', array('@menu' => url('admin/structure/menu'))) . '</dd>';
$output .= '<dd>' . t('When the site-wide contact form is enabled, a link in the <em>Footer</em> menu is created, which you can modify on the <a href="@menu">Menus administration page</a>.', array('@menu' => \Drupal::url('menu_ui.overview_page'))) . '</dd>';
$output .= '<dt>' . t('Customization') . '</dt>';
$output .= '<dd>' . t('If you would like additional text to appear on the site-wide or personal contact page, use a block. You can create and edit blocks on the <a href="@blocks">Blocks administration page</a>.', array('@blocks' => url('admin/structure/block'))) . '</dd>';
$output .= '<dd>' . t('If you would like additional text to appear on the site-wide or personal contact page, use a block. You can create and edit blocks on the <a href="@blocks">Blocks administration page</a>.', array('@blocks' => \Drupal::url('block.admin_display'))) . '</dd>';
$output .= '</dl>';
return $output;
case 'contact.form_list':
$output = '<p>' . t('Add one or more forms on this page to set up your site-wide <a href="@form">contact form</a>.', array('@form' => url('contact'))) . '</p>';
$output .= '<p>' . t('A <em>Contact</em> menu item is added to the <em>Footer</em> menu, which you can modify on the <a href="@menu-settings">Menus administration page</a>.', array('@menu-settings' => url('admin/structure/menu'))) . '</p>';
$output .= '<p>' . t('If you would like additional text to appear on the site-wide contact page, use a block. You can create and edit blocks on the <a href="@blocks">Blocks administration page</a>.', array('@blocks' => url('admin/structure/block'))) . '</p>';
$output = '<p>' . t('Add one or more forms on this page to set up your site-wide <a href="@form">contact form</a>.', array('@form' => \Drupal::url('contact.site_page'))) . '</p>';
$output .= '<p>' . t('A <em>Contact</em> menu item is added to the <em>Footer</em> menu, which you can modify on the <a href="@menu-settings">Menus administration page</a>.', array('@menu-settings' => \Drupal::url('menu_ui.overview_page'))) . '</p>';
$output .= '<p>' . t('If you would like additional text to appear on the site-wide contact page, use a block. You can create and edit blocks on the <a href="@blocks">Blocks administration page</a>.', array('@blocks' => \Drupal::url('block.admin_display'))) . '</p>';
return $output;
}
}
......@@ -127,7 +127,7 @@ function contact_mail($key, &$message, $params) {
case 'user_copy':
$variables += array(
'!recipient-name' => user_format_name($params['recipient']),
'!recipient-edit-url' => url('user/' . $params['recipient']->id() . '/edit', array('absolute' => TRUE, 'language' => $language)),
'!recipient-edit-url' => $params['recipient']->url('edit-form', array('absolute' => TRUE, 'language' => $language)),
);
$message['subject'] .= t('[!site-name] !subject', $variables, $options);
$message['body'][] = t('Hello !recipient-name,', $variables, $options);
......