PHP Class Arkade\S3\Helper\MediaStorage\File\Storage\Database\Plugin

Show file Open project: arkadedigital/magento2-s3

Public Methods

Method Description
__construct ( Data $helper, Arkade\S3\Model\MediaStorage\File\Storage\S3Factory $s3StorageFactory, Magento\MediaStorage\Model\File\Storage\DatabaseFactory $dbStorageFactory )
afterCheckDbUsage ( Magento\MediaStorage\Helper\File\Storage\Database $subject, boolean $result ) : boolean Check whether we are using either the database or S3 as our file storage backend.
afterGetMediaRelativePath ( Magento\MediaStorage\Helper\File\Storage\Database $subject, string $result ) : string The Magento_ImportExport module will try to run erroneous file paths, e.g. pub/media/catalog/category/twswifty.jpg, through the parent function of this plugin. The parent function can't handle this so it just returns the original file path (when we really don't want the pub/media prefix at all). This plugin will remove the pub/media prefix.
afterSaveUploadedFile ( Magento\MediaStorage\Helper\File\Storage\Database $subject, string $result ) : string Removes any forward slashes from the start of the uploaded file name.
aroundDeleteFolder ( Magento\MediaStorage\Helper\File\Storage\Database $subject, $proceed, $folderName )
aroundGetStorageDatabaseModel ( Magento\MediaStorage\Helper\File\Storage\Database $subject, $proceed )
aroundSaveFileToFilesystem ( Magento\MediaStorage\Helper\File\Storage\Database $subject, $proceed, $filename )

Method Details

__construct() public method

public __construct ( Data $helper, Arkade\S3\Model\MediaStorage\File\Storage\S3Factory $s3StorageFactory, Magento\MediaStorage\Model\File\Storage\DatabaseFactory $dbStorageFactory )
$helper Arkade\S3\Helper\Data
$s3StorageFactory Arkade\S3\Model\MediaStorage\File\Storage\S3Factory
$dbStorageFactory Magento\MediaStorage\Model\File\Storage\DatabaseFactory

afterCheckDbUsage() public method

Check whether we are using either the database or S3 as our file storage backend.
public afterCheckDbUsage ( Magento\MediaStorage\Helper\File\Storage\Database $subject, boolean $result ) : boolean
$subject Magento\MediaStorage\Helper\File\Storage\Database
$result boolean
return boolean

afterGetMediaRelativePath() public method

The Magento_ImportExport module will try to run erroneous file paths, e.g. pub/media/catalog/category/twswifty.jpg, through the parent function of this plugin. The parent function can't handle this so it just returns the original file path (when we really don't want the pub/media prefix at all). This plugin will remove the pub/media prefix.
public afterGetMediaRelativePath ( Magento\MediaStorage\Helper\File\Storage\Database $subject, string $result ) : string
$subject Magento\MediaStorage\Helper\File\Storage\Database
$result string
return string

afterSaveUploadedFile() public method

This addresses a bug where category pages were being saved with duplicate slashes, e.g. catalog/category//tswifty_4.jpg.
public afterSaveUploadedFile ( Magento\MediaStorage\Helper\File\Storage\Database $subject, string $result ) : string
$subject Magento\MediaStorage\Helper\File\Storage\Database
$result string
return string

aroundDeleteFolder() public method

public aroundDeleteFolder ( Magento\MediaStorage\Helper\File\Storage\Database $subject, $proceed, $folderName )
$subject Magento\MediaStorage\Helper\File\Storage\Database

aroundGetStorageDatabaseModel() public method

public aroundGetStorageDatabaseModel ( Magento\MediaStorage\Helper\File\Storage\Database $subject, $proceed )
$subject Magento\MediaStorage\Helper\File\Storage\Database

aroundSaveFileToFilesystem() public method

public aroundSaveFileToFilesystem ( Magento\MediaStorage\Helper\File\Storage\Database $subject, $proceed, $filename )
$subject Magento\MediaStorage\Helper\File\Storage\Database