Commit c205bfdb authored by catch's avatar catch
Browse files

Issue #3097534 by longwave: Remove all @deprecated code in \Drupal static service container

parent df68b011
......@@ -535,45 +535,6 @@ public static function urlGenerator() {
return static::getContainer()->get('url_generator');
}
/**
* Generates a URL string for a specific route based on the given parameters.
*
* This method is a convenience wrapper for generating URL strings for URLs
* that have Drupal routes (that is, most pages generated by Drupal) using
* the \Drupal\Core\Url object. See \Drupal\Core\Url::fromRoute() for
* detailed documentation. For non-routed local URIs relative to
* the base path (like robots.txt) use Url::fromUri()->toString() with the
* base: scheme.
*
* @param string $route_name
* The name of the route.
* @param array $route_parameters
* (optional) An associative array of parameter names and values.
* @param array $options
* (optional) An associative array of additional options.
* @param bool $collect_bubbleable_metadata
* (optional) Defaults to FALSE. When TRUE, both the generated URL and its
* associated bubbleable metadata are returned.
*
* @return string|\Drupal\Core\GeneratedUrl
* A string containing a URL to the given path.
* When $collect_bubbleable_metadata is TRUE, a GeneratedUrl object is
* returned, containing the generated URL plus bubbleable metadata.
*
* @see \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute()
* @see \Drupal\Core\Url
* @see \Drupal\Core\Url::fromRoute()
* @see \Drupal\Core\Url::fromUri()
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0.
* Instead create a \Drupal\Core\Url object directly, for example using
* Url::fromRoute().
*/
public static function url($route_name, $route_parameters = [], $options = [], $collect_bubbleable_metadata = FALSE) {
@trigger_error('Drupal::url() is deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Instead create a \Drupal\Core\Url object directly, for example using Url::fromRoute()', E_USER_DEPRECATED);
return static::getContainer()->get('url_generator')->generateFromRoute($route_name, $route_parameters, $options, $collect_bubbleable_metadata);
}
/**
* Returns the link generator service.
*
......@@ -583,33 +544,6 @@ public static function linkGenerator() {
return static::getContainer()->get('link_generator');
}
/**
* Renders a link with a given link text and Url object.
*
* This method is a convenience wrapper for the link generator service's
* generate() method.
*
* @param string $text
* The link text for the anchor tag.
* @param \Drupal\Core\Url $url
* The URL object used for the link.
*
* @return \Drupal\Core\GeneratedLink
* A GeneratedLink object containing a link to the given route and
* parameters and bubbleable metadata.
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use
* \Drupal\Core\Link::fromTextAndUrl() instead.
*
* @see https://www.drupal.org/node/2614344
* @see \Drupal\Core\Utility\LinkGeneratorInterface::generate()
* @see \Drupal\Core\Url
*/
public static function l($text, Url $url) {
@trigger_error('\Drupal::l() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Link::fromTextAndUrl() instead. See https://www.drupal.org/node/2614344', E_USER_DEPRECATED);
return static::getContainer()->get('link_generator')->generate($text, $url);
}
/**
* Returns the string translation service.
*
......
......@@ -9,7 +9,6 @@
use Drupal\Core\Entity\Query\QueryAggregateInterface;
use Drupal\Core\Entity\Query\QueryInterface;
use Drupal\Tests\UnitTestCase;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\RequestStack;
/**
......@@ -344,28 +343,6 @@ public function testUrlGenerator() {
$this->assertNotNull(\Drupal::urlGenerator());
}
/**
* Tests the url() method.
*
* @covers ::url
* @see \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute()
*
* @group legacy
* @expectedDeprecation Drupal::url() is deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Instead create a \Drupal\Core\Url object directly, for example using Url::fromRoute()
*/
public function testUrl() {
$route_parameters = ['test_parameter' => 'test'];
$options = ['test_option' => 'test'];
$generator = $this->createMock('Drupal\Core\Routing\UrlGeneratorInterface');
$generator->expects($this->once())
->method('generateFromRoute')
->with('test_route', $route_parameters, $options)
->will($this->returnValue('path_string'));
$this->setMockContainerService('url_generator', $generator);
$this->assertInternalType('string', \Drupal::url('test_route', $route_parameters, $options));
}
/**
* Tests the linkGenerator() method.
*
......@@ -376,31 +353,6 @@ public function testLinkGenerator() {
$this->assertNotNull(\Drupal::linkGenerator());
}
/**
* Tests the l() method.
*
* @covers ::l
*
* @group legacy
*
* @expectedDeprecation \Drupal::l() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Link::fromTextAndUrl() instead. See https://www.drupal.org/node/2614344
*
* @see \Drupal\Core\Utility\LinkGeneratorInterface::generate()
*/
public function testL() {
$route_parameters = ['test_parameter' => 'test'];
$options = ['test_option' => 'test'];
$generator = $this->createMock('Drupal\Core\Utility\LinkGeneratorInterface');
$url = new Url('test_route', $route_parameters, $options);
$generator->expects($this->once())
->method('generate')
->with('Test title', $url)
->will($this->returnValue('link_html_string'));
$this->setMockContainerService('link_generator', $generator);
$this->assertInternalType('string', \Drupal::l('Test title', $url));
}
/**
* Tests the translation() method.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment