Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Logo.php
Go to the documentation of this file.
1 <?php
13 
17 class Logo extends \Magento\Config\Model\Config\Backend\Image
18 {
22  const UPLOAD_DIR = 'email/logo';
23 
29  protected $_maxFileSize = 2048;
30 
36  protected function _getUploadDir()
37  {
38  return $this->_mediaDirectory->getAbsolutePath($this->_appendScopeInfo(self::UPLOAD_DIR));
39  }
40 
46  protected function _addWhetherScopeInfo()
47  {
48  return true;
49  }
50 
54  protected function getTmpFileName()
55  {
56  $tmpName = null;
57  if (isset($_FILES['groups'])) {
58  $tmpName = $_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value'];
59  } else {
60  $tmpName = is_array($this->getValue()) ? $this->getValue()['tmp_name'] : null;
61  }
62  return $tmpName;
63  }
64 
72  public function beforeSave()
73  {
74  $value = $this->getValue();
75  $deleteFlag = is_array($value) && !empty($value['delete']);
76  $fileTmpName = $this->getTmpFileName();
77 
78  if ($this->getOldValue() && ($fileTmpName || $deleteFlag)) {
79  $this->_mediaDirectory->delete(self::UPLOAD_DIR . '/' . $this->getOldValue());
80  }
81  return parent::beforeSave();
82  }
83 }
$value
Definition: gender.phtml:16