Drupal 8  8.0.2
Link Class Reference
Inheritance diagram for Link:

Public Member Functions

 __construct ($text, Url $url)
 
 getText ()
 
 setText ($text)
 
 getUrl ()
 
 setUrl (Url $url)
 
 toString ()
 
 toRenderable ()
 

Static Public Member Functions

static createFromRoute ($text, $route_name, $route_parameters=array(), $options=array())
 
static fromTextAndUrl ($text, Url $url)
 

Protected Attributes

 $text
 
 $url
 

Detailed Description

Defines an object that holds information about a link.

Constructor & Destructor Documentation

__construct (   $text,
Url  $url 
)

Constructs a new Link object.

Parameters
string$textThe text of the link.
\Drupal\Core\Url$urlThe url object.

References Drupal\url().

Here is the call graph for this function:

Member Function Documentation

static createFromRoute (   $text,
  $route_name,
  $route_parameters = array(),
  $options = array() 
)
static

Creates a Link object from a given route name and parameters.

Parameters
string$textThe text of the link.
string$route_nameThe name of the route
array$route_parameters(optional) An associative array of parameter names and values.
array$options(optional) An associative array of additional options, with the following elements:
  • 'query': An array of query key/value-pairs (without any URL-encoding) to append to the URL. Merged with the parameters array.
  • 'fragment': A fragment identifier (named anchor) to append to the URL. Do not include the leading '#' character.
  • 'absolute': Defaults to FALSE. Whether to force the output to be an absolute link (beginning with http:). Useful for links that will be displayed outside the site, such as in an RSS feed.
  • 'language': An optional language object used to look up the alias for the URL. If $options['language'] is omitted, it defaults to the current language for the language type LanguageInterface::TYPE_URL.
  • 'https': Whether this URL should point to a secure location. If not defined, the current scheme is used, so the user stays on HTTP or HTTPS respectively. TRUE enforces HTTPS and FALSE enforces HTTP.
Returns
static

Referenced by ForumNodeBreadcrumbBuilder\build(), TermBreadcrumbBuilder\build(), ForumBreadcrumbBuilderBase\build(), BookBreadcrumbBuilder\build(), PathBasedBreadcrumbBuilder\build(), ForumBreadcrumbBuilderBaseTest\testBuild(), ForumListingBreadcrumbBuilderTest\testBuild(), and ForumNodeBreadcrumbBuilderTest\testBuild().

Here is the caller graph for this function:

static fromTextAndUrl (   $text,
Url  $url 
)
static

Creates a Link object from a given Url object.

Parameters
string$textThe text of the link.
\Drupal\Core\Url$urlThe Url to create the link for.
Returns
static

Referenced by ImageFormatter\settingsForm().

Here is the caller graph for this function:

getText ( )

Returns the text of the link.

Returns
string

Referenced by LinkGenerator\generateFromLink().

Here is the caller graph for this function:

getUrl ( )

Returns the URL of the link.

Returns

Referenced by LinkGenerator\generateFromLink().

Here is the caller graph for this function:

setText (   $text)

Sets the new text of the link.

Parameters
string$textThe new text.
Returns
$this
setUrl ( Url  $url)

Sets the URL of this link.

Parameters
Url$urlThe URL object to set
Returns
$this

References Drupal\url().

Here is the call graph for this function:

toRenderable ( )

{Returns a render array representation of the object.

Returns
mixed[] A render array.
}

Implements RenderableInterface.

toString ( )

Generates the HTML for this Link object.

Do not use this method to render a link in an HTML context. In an HTML context, self::toRenderable() should be used so that render cache information is maintained. However, there might be use cases such as tests and non-HTML contexts where calling this method directly makes sense.

Returns
The link HTML markup.
See Also
::toRenderable()

The documentation for this class was generated from the following file: