class Link in Zircon Profile 8
Same name in this branch
- 8 vendor/symfony/dom-crawler/Link.php \Symfony\Component\DomCrawler\Link
- 8 core/lib/Drupal/Core/Link.php \Drupal\Core\Link
- 8 core/lib/Drupal/Core/Render/Element/Link.php \Drupal\Core\Render\Element\Link
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Render/Element/Link.php \Drupal\Core\Render\Element\Link
Provides a link render element.
Plugin annotation
@RenderElement("link");
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, StringTranslationTrait
- class \Drupal\Core\Render\Element\RenderElement implements ElementInterface
- class \Drupal\Core\Render\Element\Link
- class \Drupal\Core\Render\Element\RenderElement implements ElementInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, StringTranslationTrait
Expanded class hierarchy of Link
11 string references to 'Link'
- contextual.views.schema.yml in core/
modules/ contextual/ config/ schema/ contextual.views.schema.yml - core/modules/contextual/config/schema/contextual.views.schema.yml
- DrupalLink::getButtons in core/
modules/ ckeditor/ src/ Plugin/ CKEditorPlugin/ DrupalLink.php - Returns the buttons that this plugin provides, along with metadata.
- FieldHelpTest::testFieldHelp in core/
modules/ field/ src/ Tests/ FieldHelpTest.php - Test the Field module's help page.
- HtmlResponseAttachmentsProcessor::processHtmlHeadLink in core/
lib/ Drupal/ Core/ Render/ HtmlResponseAttachmentsProcessor.php - Transform a html_head_link array into html_head and http_header arrays.
- link.info.yml in core/
modules/ link/ link.info.yml - core/modules/link/link.info.yml
66 #type uses of Link
- AggregatorFeedBlock::build in core/
modules/ aggregator/ src/ Plugin/ Block/ AggregatorFeedBlock.php - Builds and returns the renderable array for this block plugin.
- AggregatorTitleFormatter::viewElements in core/
modules/ aggregator/ src/ Plugin/ Field/ FieldFormatter/ AggregatorTitleFormatter.php - Builds a renderable array for a field value.
- AjaxTestController::dialog in core/
modules/ system/ tests/ modules/ ajax_test/ src/ Controller/ AjaxTestController.php - Returns a render array of form elements and links for dialog.
- AjaxTestController::dialogContents in core/
modules/ system/ tests/ modules/ ajax_test/ src/ Controller/ AjaxTestController.php - Example content for dialog testing.
- authorize.php in core/
authorize.php - Administrative script for running authorized file operations.
File
- core/
lib/ Drupal/ Core/ Render/ Element/ Link.php, line 20 - Contains \Drupal\Core\Render\Element\Link.
Namespace
Drupal\Core\Render\ElementView source
class Link extends RenderElement {
/**
* {@inheritdoc}
*/
public function getInfo() {
$class = get_class($this);
return array(
'#pre_render' => array(
array(
$class,
'preRenderLink',
),
),
);
}
/**
* Pre-render callback: Renders a link into #markup.
*
* Doing so during pre_render gives modules a chance to alter the link parts.
*
* @param array $element
* A structured array whose keys form the arguments to
* \Drupal\Core\Utility\LinkGeneratorInterface::generate():
* - #title: The link text.
* - #url: The URL info either pointing to a route or a non routed path.
* - #options: (optional) An array of options to pass to the link generator.
*
* @return array
* The passed-in element containing a rendered link in '#markup'.
*/
public static function preRenderLink($element) {
// By default, link options to pass to the link generator are normally set
// in #options.
$element += array(
'#options' => array(),
);
// However, within the scope of renderable elements, #attributes is a valid
// way to specify attributes, too. Take them into account, but do not override
// attributes from #options.
if (isset($element['#attributes'])) {
$element['#options'] += array(
'attributes' => array(),
);
$element['#options']['attributes'] += $element['#attributes'];
}
// This #pre_render callback can be invoked from inside or outside of a Form
// API context, and depending on that, a HTML ID may be already set in
// different locations. #options should have precedence over Form API's #id.
// #attributes have been taken over into #options above already.
if (isset($element['#options']['attributes']['id'])) {
$element['#id'] = $element['#options']['attributes']['id'];
}
elseif (isset($element['#id'])) {
$element['#options']['attributes']['id'] = $element['#id'];
}
// Conditionally invoke self::preRenderAjaxForm(), if #ajax is set.
if (isset($element['#ajax']) && !isset($element['#ajax_processed'])) {
// If no HTML ID was found above, automatically create one.
if (!isset($element['#id'])) {
$element['#id'] = $element['#options']['attributes']['id'] = HtmlUtility::getUniqueId('ajax-link');
}
$element = static::preRenderAjaxForm($element);
}
if (!empty($element['#url']) && $element['#url'] instanceof CoreUrl) {
$options = NestedArray::mergeDeep($element['#url']
->getOptions(), $element['#options']);
/** @var \Drupal\Core\Utility\LinkGenerator $link_generator */
$link_generator = \Drupal::service('link_generator');
$generated_link = $link_generator
->generate($element['#title'], $element['#url']
->setOptions($options));
$element['#markup'] = $generated_link
->getGeneratedLink();
$generated_link
->merge(BubbleableMetadata::createFromRenderArray($element))
->applyTo($element);
}
return $element;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
Link:: |
public | function |
Returns the element properties for this element. Overrides ElementInterface:: |
2 |
Link:: |
public static | function | Pre-render callback: Renders a link into #markup. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 2 |
PluginBase:: |
protected | property | The plugin implementation definition. | |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Constructs a Drupal\Component\Plugin\PluginBase object. | 69 |
RenderElement:: |
public static | function | Adds Ajax information about an element to communicate with JavaScript. | |
RenderElement:: |
public static | function | Adds members of this group as actual elements for rendering. | |
RenderElement:: |
public static | function | Form element processing handler for the #ajax form property. | |
RenderElement:: |
public static | function | Arranges elements into groups. | |
RenderElement:: |
public static | function |
Sets a form element's class attribute. Overrides ElementInterface:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |