class Url
Same name in this branch
- 9 core/lib/Drupal/Core/Render/Element/Url.php \Drupal\Core\Render\Element\Url
- 9 core/lib/Drupal/Core/Url.php \Drupal\Core\Url
Same name and namespace in other branches
- 11.x core/modules/views/src/Plugin/views/field/Url.php \Drupal\views\Plugin\views\field\Url
- 11.x core/lib/Drupal/Core/Render/Element/Url.php \Drupal\Core\Render\Element\Url
- 11.x core/lib/Drupal/Core/Url.php \Drupal\Core\Url
- 10 core/modules/views/src/Plugin/views/field/Url.php \Drupal\views\Plugin\views\field\Url
- 10 core/lib/Drupal/Core/Render/Element/Url.php \Drupal\Core\Render\Element\Url
- 10 core/lib/Drupal/Core/Url.php \Drupal\Core\Url
- 8.9.x core/modules/views/src/Plugin/views/field/Url.php \Drupal\views\Plugin\views\field\Url
- 8.9.x core/lib/Drupal/Core/Render/Element/Url.php \Drupal\Core\Render\Element\Url
- 8.9.x core/lib/Drupal/Core/Url.php \Drupal\Core\Url
Field handler to provide simple renderer that turns a URL into a clickable link.
Plugin annotation
@ViewsField("url");
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
- class \Drupal\views\Plugin\views\PluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\views\Plugin\views\HandlerBase implements \Drupal\views\Plugin\views\ViewsHandlerInterface extends \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\field\FieldPluginBase implements \Drupal\views\Plugin\views\field\FieldHandlerInterface extends \Drupal\views\Plugin\views\HandlerBase
- class \Drupal\views\Plugin\views\field\Url extends \Drupal\views\Plugin\views\field\FieldPluginBase
- class \Drupal\views\Plugin\views\field\FieldPluginBase implements \Drupal\views\Plugin\views\field\FieldHandlerInterface extends \Drupal\views\Plugin\views\HandlerBase
- class \Drupal\views\Plugin\views\HandlerBase implements \Drupal\views\Plugin\views\ViewsHandlerInterface extends \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\PluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of Url
Related topics
150 string references to 'Url'
- AggregatorFeedViewsFieldAccessTest::testAggregatorFeedFields in core/
modules/ aggregator/ tests/ src/ Kernel/ Views/ AggregatorFeedViewsFieldAccessTest.php - Checks access for aggregator_feed fields.
- AliasPathProcessorTest::providerTestProcessOutbound in core/
modules/ path_alias/ tests/ src/ Unit/ PathProcessor/ AliasPathProcessorTest.php - AliasPathProcessorTest::testProcessInbound in core/
modules/ path_alias/ tests/ src/ Unit/ PathProcessor/ AliasPathProcessorTest.php - Tests the processInbound method.
- AliasPathProcessorTest::testProcessOutbound in core/
modules/ path_alias/ tests/ src/ Unit/ PathProcessor/ AliasPathProcessorTest.php - @covers ::processOutbound[[api-linebreak]]
- ArgumentPluginBase::getCacheContexts in core/
modules/ views/ src/ Plugin/ views/ argument/ ArgumentPluginBase.php
File
-
core/
modules/ views/ src/ Plugin/ views/ field/ Url.php, line 17
Namespace
Drupal\views\Plugin\views\fieldView source
class Url extends FieldPluginBase {
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['display_as_link'] = [
'default' => TRUE,
];
return $options;
}
/**
* Provide link to the page being visited.
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['display_as_link'] = [
'#title' => $this->t('Display as link'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['display_as_link']),
];
parent::buildOptionsForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$value = $this->getValue($values);
if (!empty($this->options['display_as_link'])) {
// @todo Views should expect and store a leading /. See:
// https://www.drupal.org/node/2423913
return Link::fromTextAndUrl($this->sanitizeValue($value), CoreUrl::fromUserInput('/' . $value))
->toString();
}
else {
return $this->sanitizeValue($value, 'url');
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.