Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FileFactory.php
Go to the documentation of this file.
1 <?php
7 
9 
14 class FileFactory extends \Magento\Framework\App\Response\Http\FileFactory
15 {
19  protected $_auth;
20 
24  protected $_backendUrl;
25 
29  protected $_response;
30 
34  protected $_session;
35 
39  protected $_flag;
40 
44  protected $_helper;
45 
55  public function __construct(
56  \Magento\Framework\App\ResponseInterface $response,
57  \Magento\Framework\Filesystem $filesystem,
58  \Magento\Backend\Model\Auth $auth,
59  \Magento\Backend\Model\UrlInterface $backendUrl,
60  \Magento\Backend\Model\Session $session,
61  \Magento\Framework\App\ActionFlag $flag,
62  \Magento\Backend\Helper\Data $helper
63  ) {
64  $this->_auth = $auth;
65  $this->_backendUrl = $backendUrl;
66  $this->_session = $session;
67  $this->_flag = $flag;
68  $this->_helper = $helper;
69  parent::__construct($response, $filesystem);
70  }
71 
80  protected function _redirect($path, $arguments = [])
81  {
82  $this->_session->setIsUrlNotice(
83  $this->_flag->get('', \Magento\Backend\App\AbstractAction::FLAG_IS_URLS_CHECKED)
84  );
85  $this->_response->setRedirect($this->_helper->getUrl($path, $arguments));
86  return $this->_response;
87  }
88 
100  public function create(
101  $fileName,
102  $content,
104  $contentType = 'application/octet-stream',
105  $contentLength = null
106  ) {
107  if ($this->_auth->getAuthStorage()->isFirstPageAfterLogin()) {
108  return $this->_redirect($this->_backendUrl->getStartupPageUrl());
109  }
110  return parent::create($fileName, $content, $baseDir, $contentType, $contentLength);
111  }
112 }
$response
Definition: 404.php:11
$helper
Definition: iframe.phtml:13
$baseDir
Definition: autoload.php:9
__construct(\Magento\Framework\App\ResponseInterface $response, \Magento\Framework\Filesystem $filesystem, \Magento\Backend\Model\Auth $auth, \Magento\Backend\Model\UrlInterface $backendUrl, \Magento\Backend\Model\Session $session, \Magento\Framework\App\ActionFlag $flag, \Magento\Backend\Helper\Data $helper)
Definition: FileFactory.php:55
$fileName
Definition: translate.phtml:15
create( $fileName, $content, $baseDir=DirectoryList::ROOT, $contentType='application/octet-stream', $contentLength=null)
$arguments
$filesystem