Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
@ -7,13 +7,17 @@
|
|||
|
||||
namespace Drupal\Core;
|
||||
|
||||
use Drupal\Core\Render\RenderableInterface;
|
||||
use Drupal\Core\Routing\LinkGeneratorTrait;
|
||||
|
||||
/**
|
||||
* Defines an object that holds information about a link.
|
||||
*/
|
||||
class Link {
|
||||
class Link implements RenderableInterface {
|
||||
|
||||
/**
|
||||
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
|
||||
*/
|
||||
use LinkGeneratorTrait;
|
||||
|
||||
/**
|
||||
|
@ -44,7 +48,7 @@ class Link {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a link object from a given route name and parameters.
|
||||
* Creates a Link object from a given route name and parameters.
|
||||
*
|
||||
* @param string $text
|
||||
* The text of the link.
|
||||
|
@ -75,6 +79,20 @@ class Link {
|
|||
return new static($text, new Url($route_name, $route_parameters, $options));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Link object from a given Url object.
|
||||
*
|
||||
* @param string $text
|
||||
* The text of the link.
|
||||
* @param \Drupal\Core\Url $url
|
||||
* The Url to create the link for.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function fromTextAndUrl($text, Url $url) {
|
||||
return new static($text, $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the text of the link.
|
||||
*
|
||||
|
@ -122,17 +140,25 @@ class Link {
|
|||
/**
|
||||
* Generates the HTML for this Link object.
|
||||
*
|
||||
* @param bool $collect_bubbleable_metadata
|
||||
* (optional) Defaults to FALSE. When TRUE, both the generated link and its
|
||||
* associated bubbleable metadata are returned.
|
||||
*
|
||||
* @return string|\Drupal\Core\GeneratedLink
|
||||
* @return \Drupal\Core\GeneratedLink
|
||||
* The link HTML markup.
|
||||
* When $collect_bubbleable_metadata is TRUE, a GeneratedLink object is
|
||||
* returned, containing the generated link plus bubbleable metadata.
|
||||
*
|
||||
* @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0. Use
|
||||
* self::toRenderable() instead.
|
||||
*/
|
||||
public function toString($collect_bubbleable_metadata = FALSE) {
|
||||
return $this->getLinkGenerator()->generateFromLink($this, $collect_bubbleable_metadata);
|
||||
public function toString() {
|
||||
return $this->getLinkGenerator()->generateFromLink($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toRenderable() {
|
||||
return [
|
||||
'#type' => 'link',
|
||||
'#url' => $this->url,
|
||||
'#title' => $this->text,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue