You are here

class AcsfDuplicationScrubTemporaryFilesHandler in Acquia Cloud Site Factory Connector 8.2

Same name and namespace in other branches
  1. 8 src/Event/AcsfDuplicationScrubTemporaryFilesHandler.php \Drupal\acsf\Event\AcsfDuplicationScrubTemporaryFilesHandler

Handles the scrubbing of Drupal temporary files.

Hierarchy

Expanded class hierarchy of AcsfDuplicationScrubTemporaryFilesHandler

File

src/Event/AcsfDuplicationScrubTemporaryFilesHandler.php, line 8

Namespace

Drupal\acsf\Event
View source
class AcsfDuplicationScrubTemporaryFilesHandler extends AcsfEventHandler {

  /**
   * Implements AcsfEventHandler::handle().
   */
  public function handle() {
    $this
      ->consoleLog(dt('Entered @class', [
      '@class' => get_class($this),
    ]));
    $file_storage = \Drupal::entityTypeManager()
      ->getStorage('file');

    // Remove all temporary files. As in file_cron(), temporary is encoded as
    // "<> FILE_STATUS_PERMANENT".
    $fids = $file_storage
      ->getQuery()
      ->condition('status', FILE_STATUS_PERMANENT, '<>')
      ->range(0, 1000)
      ->execute();
    $files = $file_storage
      ->loadMultiple($fids);
    foreach ($files as $file) {
      $file
        ->delete();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AcsfDuplicationScrubTemporaryFilesHandler::handle public function Implements AcsfEventHandler::handle(). Overrides AcsfEventHandler::handle
AcsfEventHandler::$completed public property The time that the handler was completed.
AcsfEventHandler::$message public property Any messages triggered by the handler.
AcsfEventHandler::$started public property The time that the handler was started.
AcsfEventHandler::consoleLog public function Writes a log message to the console.
AcsfEventHandler::__construct public function Constructor. 1