Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SignalSlotDispatcher in the getFileForLocalProcessing function. #38

Merged
merged 1 commit into from
Jul 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Classes/Driver/AmazonS3Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use TYPO3\CMS\Core\Resource\ResourceStorage;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;

/**
Expand Down Expand Up @@ -149,6 +150,11 @@ class AmazonS3Driver extends AbstractHierarchicalFilesystemDriver
*/
protected $temporaryPaths = [];

/**
* @var Dispatcher
*/
protected $signalSlotDispatcher;

/**
* AmazonS3Driver constructor.
*
Expand Down Expand Up @@ -499,12 +505,29 @@ public function getFileForLocalProcessing($fileIdentifier, $writable = true)
if (!is_file($temporaryPath)) {
throw new \RuntimeException('Copying file ' . $fileIdentifier . ' to temporary path failed.', 1320577649);
}
$this->emitGetFileForLocalProcessingSignal($fileIdentifier, $temporaryPath, $writable);
if (!isset($this->temporaryPaths[$temporaryPath])) {
$this->temporaryPaths[$temporaryPath] = $temporaryPath;
}
return $temporaryPath;
}

/**
* @param string $fileIdentifier
* @param string $temporaryPath
* @param bool $writable
* @throws \TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotException
* @throws \TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotReturnException
*/
protected function emitGetFileForLocalProcessingSignal(&$fileIdentifier, &$temporaryPath, &$writable)
{
list($fileIdentifier, $temporaryPath, $writable) = $this->getSignalSlotDispatcher()->dispatch(
self::class,
'getFileForLocalProcessing',
[$fileIdentifier, $temporaryPath, $writable]
);
}

/**
* Creates a new (empty) file and returns the identifier.
*
Expand Down Expand Up @@ -1602,4 +1625,17 @@ protected function applyFilterMethodsToDirectoryItem(array $filterMethods, $item
}
return true;
}

/**
* Get the SignalSlot dispatcher
*
* @return Dispatcher
*/
protected function getSignalSlotDispatcher()
{
if (!isset($this->signalSlotDispatcher)) {
$this->signalSlotDispatcher = GeneralUtility::makeInstance(ObjectManager::class)->get(Dispatcher::class);
}
return $this->signalSlotDispatcher;
}
}