trait FileProcessorTrait in Backup and Migrate 5.0.x
Implement the injection functionality of a file processor.
@package Drupal\backup_migrate\Core\Plugin
Hierarchy
- trait \Drupal\backup_migrate\Core\Plugin\FileProcessorTrait
8 files declare their use of FileProcessorTrait
- CompressionFilter.php in src/
Core/ Filter/ CompressionFilter.php - DatabaseSource.php in src/
Core/ Source/ DatabaseSource.php - DrupalEncrypt.php in src/
Drupal/ Filter/ DrupalEncrypt.php - FileDirectorySource.php in src/
Core/ Source/ FileDirectorySource.php - FileNamer.php in src/
Core/ Filter/ FileNamer.php
File
- src/
Core/ Plugin/ FileProcessorTrait.php, line 12
Namespace
Drupal\backup_migrate\Core\PluginView source
trait FileProcessorTrait {
/**
* @var \Drupal\backup_migrate\Core\File\TempFileManagerInterface
*/
protected $tempfilemanager;
/**
* Inject the temp file manager.
*
* @param \Drupal\backup_migrate\Core\File\TempFileManagerInterface $tempfilemanager
*
* @return mixed
*/
public function setTempFileManager(TempFileManagerInterface $tempfilemanager) {
$this->tempfilemanager = $tempfilemanager;
}
/**
* Get the temp file manager.
*
* @return \Drupal\backup_migrate\Core\File\TempFileManagerInterface
*/
public function getTempFileManager() {
return $this->tempfilemanager;
}
/**
* Provide the file mime for the given file extension if known.
*
* @param string $filemime
* The best guess so far for the file's mime type.
* @param array $params
* A list of parameters where
* 'ext' is the file extension we are testing.
*
* @return string
* The mime type of the file (or the passed in mime type if unknown)
*/
public function alterMime($filemime, array $params) {
// Check all of the provided file types for the given extension.
if (method_exists($this, 'getFileTypes')) {
$file_types = $this
->getFileTypes();
foreach ($file_types as $info) {
if (isset($info['extension']) && $info['extension'] == $params['ext'] && isset($info['filemime'])) {
return $info['filemime'];
}
}
}
return $filemime;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FileProcessorTrait:: |
protected | property | ||
FileProcessorTrait:: |
public | function | Provide the file mime for the given file extension if known. | |
FileProcessorTrait:: |
public | function | Get the temp file manager. | |
FileProcessorTrait:: |
public | function | Inject the temp file manager. |