eZ\Publish\Core\FieldType\BinaryBase\BinaryBaseStorage::removeOldFile PHP Method

removeOldFile() protected method

Removes the old file referenced by $fieldId in $versionNo, if not referenced else where.
protected removeOldFile ( mixed $fieldId, string $versionNo, array $context )
$fieldId mixed
$versionNo string
$context array
    protected function removeOldFile($fieldId, $versionNo, array $context)
    {
        $gateway = $this->getGateway($context);
        $fileReference = $gateway->getFileReferenceData($fieldId, $versionNo);
        if ($fileReference === null) {
            // No previous file
            return;
        }
        $gateway->removeFileReference($fieldId, $versionNo);
        $fileCounts = $gateway->countFileReferences(array($fileReference['id']));
        if ($fileCounts[$fileReference['id']] === 0) {
            $binaryFile = $this->IOService->loadBinaryFile($fileReference['id']);
            $this->IOService->deleteBinaryFile($binaryFile);
        }
    }