class GetImageSize in File metadata manager 8
Same name and namespace in other branches
- 8.2 src/Plugin/FileMetadata/GetImageSize.php \Drupal\file_mdm\Plugin\FileMetadata\GetImageSize
FileMetadata plugin for getimagesize.
Plugin annotation
@FileMetadata(
id = "getimagesize",
title = @Translation("Getimagesize"),
help = @Translation("File metadata plugin for PHP getimagesize()."),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\file_mdm\Plugin\FileMetadata\FileMetadataPluginBase implements FileMetadataPluginInterface
- class \Drupal\file_mdm\Plugin\FileMetadata\GetImageSize
- class \Drupal\file_mdm\Plugin\FileMetadata\FileMetadataPluginBase implements FileMetadataPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of GetImageSize
File
- src/
Plugin/ FileMetadata/ GetImageSize.php, line 16
Namespace
Drupal\file_mdm\Plugin\FileMetadataView source
class GetImageSize extends FileMetadataPluginBase {
/**
* {@inheritdoc}
*/
public function getSupportedKeys($options = NULL) {
return [
0,
1,
2,
3,
'mime',
'channels',
'bits',
];
}
/**
* {@inheritdoc}
*/
protected function doGetMetadataFromFile() {
if ($data = @getimagesize($this
->getLocalTempPath())) {
return $data;
}
else {
return NULL;
}
}
/**
* Validates a file metadata key.
*
* @return bool
* TRUE if the key is valid.
*
* @throws \Drupal\file_mdm\FileMetadataException
* In case the key is invalid.
*/
protected function validateKey($key, $method) {
if (!is_int($key) && !is_string($key)) {
throw new FileMetadataException("Invalid metadata key specified", $this
->getPluginId(), $method);
}
if (!in_array($key, $this
->getSupportedKeys(), TRUE)) {
throw new FileMetadataException("Invalid metadata key '{$key}' specified", $this
->getPluginId(), $method);
}
return TRUE;
}
/**
* {@inheritdoc}
*/
protected function doGetMetadata($key = NULL) {
if ($key === NULL) {
return $this->metadata;
}
else {
$this
->validateKey($key, __FUNCTION__);
return isset($this->metadata[$key]) ? $this->metadata[$key] : NULL;
}
}
/**
* {@inheritdoc}
*/
protected function doSetMetadata($key, $value) {
$this
->validateKey($key, __FUNCTION__);
$this->metadata[$key] = $value;
return TRUE;
}
/**
* {@inheritdoc}
*/
protected function doRemoveMetadata($key) {
$this
->validateKey($key, __FUNCTION__);
if (isset($this->metadata[$key])) {
unset($this->metadata[$key]);
}
return TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FileMetadataPluginBase:: |
protected | property | The cache service. | |
FileMetadataPluginBase:: |
protected | property | The config factory. | |
FileMetadataPluginBase:: |
protected | property | The hash used to reference the URI. | |
FileMetadataPluginBase:: |
protected | property | Track if file metadata on cache needs update. | |
FileMetadataPluginBase:: |
protected | property | Track if metadata has been changed from version on file. | |
FileMetadataPluginBase:: |
protected | property | The metadata loading status. | |
FileMetadataPluginBase:: |
protected | property | The local filesystem path to the file. | |
FileMetadataPluginBase:: |
protected | property | The metadata of the file. | |
FileMetadataPluginBase:: |
protected | property | The URI of the file. | |
FileMetadataPluginBase:: |
public | function |
Form constructor. Overrides PluginFormInterface:: |
|
FileMetadataPluginBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
1 |
FileMetadataPluginBase:: |
public static | function |
Gets default configuration for this plugin. Overrides FileMetadataPluginInterface:: |
|
FileMetadataPluginBase:: |
public | function |
Removes cached metadata for file at URI. Overrides FileMetadataPluginInterface:: |
|
FileMetadataPluginBase:: |
protected | function | Saves metadata to file at URI. | 1 |
FileMetadataPluginBase:: |
protected | function | Gets the configuration object for this plugin. | |
FileMetadataPluginBase:: |
public | function |
Gets the local filesystem path to the file. Overrides FileMetadataPluginInterface:: |
|
FileMetadataPluginBase:: |
public | function |
Gets a metadata element. Overrides FileMetadataPluginInterface:: |
|
FileMetadataPluginBase:: |
protected | function | Gets metadata to save to cache. | |
FileMetadataPluginBase:: |
public | function |
Gets the URI of the file. Overrides FileMetadataPluginInterface:: |
|
FileMetadataPluginBase:: |
public | function |
Checks if file metadata has been already loaded. Overrides FileMetadataPluginInterface:: |
|
FileMetadataPluginBase:: |
public | function |
Determines if plugin is capable of writing metadata to files. Overrides FileMetadataPluginInterface:: |
1 |
FileMetadataPluginBase:: |
protected | function | Checks if file metadata should be cached. | |
FileMetadataPluginBase:: |
public | function |
Loads file metadata from an in-memory object/array. Overrides FileMetadataPluginInterface:: |
|
FileMetadataPluginBase:: |
public | function |
Loads file metadata from a cache entry. Overrides FileMetadataPluginInterface:: |
|
FileMetadataPluginBase:: |
public | function |
Loads file metadata from the file at URI/local path. Overrides FileMetadataPluginInterface:: |
|
FileMetadataPluginBase:: |
public | function |
Removes a metadata element. Overrides FileMetadataPluginInterface:: |
|
FileMetadataPluginBase:: |
public | function |
Caches metadata for file at URI. Overrides FileMetadataPluginInterface:: |
|
FileMetadataPluginBase:: |
public | function |
Saves metadata to file at URI. Overrides FileMetadataPluginInterface:: |
|
FileMetadataPluginBase:: |
public | function |
Sets the hash used to reference the URI by the metadata manager. Overrides FileMetadataPluginInterface:: |
|
FileMetadataPluginBase:: |
public | function |
Sets the local filesystem path to the file. Overrides FileMetadataPluginInterface:: |
|
FileMetadataPluginBase:: |
public | function |
Sets a metadata element. Overrides FileMetadataPluginInterface:: |
|
FileMetadataPluginBase:: |
public | function |
Sets the URI of the file. Overrides FileMetadataPluginInterface:: |
|
FileMetadataPluginBase:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
|
FileMetadataPluginBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
|
FileMetadataPluginBase:: |
public | function |
Constructs a FileMetadataPluginBase plugin. Overrides PluginBase:: |
1 |
GetImageSize:: |
protected | function |
Gets a metadata element. Overrides FileMetadataPluginBase:: |
|
GetImageSize:: |
protected | function |
Gets file metadata from the file at URI/local path. Overrides FileMetadataPluginBase:: |
|
GetImageSize:: |
protected | function |
Removes a metadata element. Overrides FileMetadataPluginBase:: |
|
GetImageSize:: |
protected | function |
Sets a metadata element. Overrides FileMetadataPluginBase:: |
|
GetImageSize:: |
public | function |
Returns a list of metadata keys supported by the plugin. Overrides FileMetadataPluginInterface:: |
|
GetImageSize:: |
protected | function | Validates a file metadata key. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
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. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
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. |