26 lines
		
	
	
		
			699 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			26 lines
		
	
	
		
			699 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| 
								 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @file
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use Drupal\Core\Link;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * Prepares variables for separated link field templates.
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * This template outputs a separate title and link.
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * Default template: link-formatter-link-separate.html.twig.
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @param array $variables
							 | 
						||
| 
								 | 
							
								 *   An associative array containing:
							 | 
						||
| 
								 | 
							
								 *   - title: (optional) A descriptive or alternate title for the link, which
							 | 
						||
| 
								 | 
							
								 *     may be different than the actual link text.
							 | 
						||
| 
								 | 
							
								 *   - url_title: The anchor text for the link.
							 | 
						||
| 
								 | 
							
								 *   - url: A \Drupal\Core\Url object.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								function template_preprocess_link_formatter_link_separate(&$variables): void {
							 | 
						||
| 
								 | 
							
								  $variables['link'] = Link::fromTextAndUrl($variables['url_title'], $variables['url'])->toString();
							 | 
						||
| 
								 | 
							
								}
							 |