| Current Path : /home/rtorresani/www/vendor/magento/module-config/Model/Config/Backend/Email/ |
| Current File : //home/rtorresani/www/vendor/magento/module-config/Model/Config/Backend/Email/Logo.php |
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Backend model for uploading transactional emails custom logo image
*
* @author Magento Core Team <core@magentocommerce.com>
*/
namespace Magento\Config\Model\Config\Backend\Email;
/**
* @deprecated 100.1.5
*/
class Logo extends \Magento\Config\Model\Config\Backend\Image
{
/**
* The tail part of directory path for uploading
*/
const UPLOAD_DIR = 'email/logo';
/**
* Upload max file size in kilobytes
*
* @var int
*/
protected $_maxFileSize = 2048;
/**
* Return path to directory for upload file
*
* @return string
*/
protected function _getUploadDir()
{
return $this->_mediaDirectory->getAbsolutePath($this->_appendScopeInfo(self::UPLOAD_DIR));
}
/**
* Makes a decision about whether to add info about the scope
*
* @return boolean
*/
protected function _addWhetherScopeInfo()
{
return true;
}
/**
* @return string|null
*/
protected function getTmpFileName()
{
$tmpName = null;
if (isset($_FILES['groups'])) {
$tmpName = $_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value'];
} else {
$tmpName = is_array($this->getValue()) ? $this->getValue()['tmp_name'] : null;
}
return $tmpName;
}
/**
* Save uploaded file before saving config value
*
* Save changes and delete file if "delete" option passed
*
* @return $this
*/
public function beforeSave()
{
$value = $this->getValue();
$deleteFlag = is_array($value) && !empty($value['delete']);
$fileTmpName = $this->getTmpFileName();
if ($this->getOldValue() && ($fileTmpName || $deleteFlag)) {
$this->_mediaDirectory->delete(self::UPLOAD_DIR . '/' . $this->getOldValue());
}
return parent::beforeSave();
}
}