You are here

trait FileProcessorTrait in Backup and Migrate 8.4

Class FileProcessorPluginTrait.

@package BackupMigrate\Core\Plugin

Implement the injection functionality of a file processor.

Hierarchy

9 files declare their use of FileProcessorTrait
CompressionFilter.php in lib/backup_migrate_core/src/Filter/CompressionFilter.php
DatabaseSource.php in lib/backup_migrate_core/src/Source/DatabaseSource.php
DrupalEncrypt.php in src/Filter/DrupalEncrypt.php
DrupalSiteArchiveSource.php in src/Source/DrupalSiteArchiveSource.php
FileDirectorySource.php in lib/backup_migrate_core/src/Source/FileDirectorySource.php

... See full list

File

lib/backup_migrate_core/src/Plugin/FileProcessorTrait.php, line 14

Namespace

BackupMigrate\Core\Plugin
View source
trait FileProcessorTrait {

  /**
   * @var TempFileManagerInterface
   */
  protected $tempfilemanager;

  /**
   * Inject the temp file manager.
   *
   * @param \BackupMigrate\Core\File\TempFileManagerInterface $tempfilemanager
   *
   * @return mixed
   */
  public function setTempFileManager(TempFileManagerInterface $tempfilemanager) {
    $this->tempfilemanager = $tempfilemanager;
  }

  /**
   * Get the temp file manager.
   *
   * @return \BackupMigrate\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, $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

Namesort descending Modifiers Type Description Overrides
FileProcessorTrait::$tempfilemanager protected property
FileProcessorTrait::alterMime public function Provide the file mime for the given file extension if known.
FileProcessorTrait::getTempFileManager public function Get the temp file manager.
FileProcessorTrait::setTempFileManager public function Inject the temp file manager.