You are here

FileDetermineType.php in File Entity (fieldable files) 8.2

File

src/Plugin/QueueWorker/FileDetermineType.php
View source
<?php

namespace Drupal\file_entity\Plugin\QueueWorker;

use Drupal\Core\Queue\QueueWorkerBase;
use Drupal\file\Entity\File;

/**
 * @QueueWorker(
 *   id = "file_entity_type_determine",
 *   title = @Translation("Determine file type"),
 *   cron = {"time" = 60}
 * )
 */
class FileDetermineType extends QueueWorkerBase {

  /**
   * {@inheritdoc}
   */
  public function processItem($data) {
    if ($file = File::load($data)) {

      // The file type will be automatically determined when saving the file.
      $file
        ->save();
    }
  }

}

Classes

Namesort descending Description
FileDetermineType Plugin annotation @QueueWorker( id = "file_entity_type_determine", title = @Translation("Determine file type"), cron = {"time" = 60} )