class File in Linkit 8.5
A substitution plugin for the URL to a file.
Plugin annotation
@Substitution(
id = "file",
label = @Translation("Direct File URL"),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\linkit\Plugin\Linkit\Substitution\File implements SubstitutionInterface
Expanded class hierarchy of File
1 file declares its use of File
- SubstitutionPluginTest.php in tests/
src/ Kernel/ SubstitutionPluginTest.php
File
- src/
Plugin/ Linkit/ Substitution/ File.php, line 19
Namespace
Drupal\linkit\Plugin\Linkit\SubstitutionView source
class File extends PluginBase implements SubstitutionInterface {
/**
* {@inheritdoc}
*/
public function getUrl(EntityInterface $entity) {
$url = new GeneratedUrl();
/** @var \Drupal\file\FileInterface $entity */
$url
->setGeneratedUrl(file_create_url($entity
->getFileUri()));
$url
->addCacheableDependency($entity);
return $url;
}
/**
* {@inheritdoc}
*/
public static function isApplicable(EntityTypeInterface $entity_type) {
return $entity_type
->entityClassImplements('Drupal\\file\\FileInterface');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
File:: |
public | function |
Get the URL associated with a given entity. Overrides SubstitutionInterface:: |
|
File:: |
public static | function |
Checks if this substitution plugin is applicable for the given entity type. Overrides SubstitutionInterface:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
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:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |