12 class Link extends \Magento\Catalog\Controller\Adminhtml\Product\Edit
19 return $this->_objectManager->create(\
Magento\Downloadable\Model\Link::class);
27 return $this->_objectManager->get(\
Magento\Downloadable\Model\Link::class);
37 protected function _processDownload(
$resource, $resourceType)
40 $helper = $this->_objectManager->get(\
Magento\Downloadable\Helper\Download::class);
44 $contentType =
$helper->getContentType();
56 'must-revalidate, post-check=0, pre-check=0',
64 if ($fileSize =
$helper->getFileSize()) {
65 $response->setHeader(
'Content-Length', $fileSize);
69 $contentDisposition =
$helper->getContentDisposition();
70 if (!$contentDisposition || $contentType ===
'text/html') {
71 $contentDisposition =
'attachment';
74 'Content-Disposition',
75 $contentDisposition .
'; filename=' .
$fileName 91 $linkId = $this->
getRequest()->getParam(
'id', 0);
98 if (
$type ==
'link') {
99 if (
$link->getLinkType() == DownloadHelper::LINK_TYPE_URL) {
101 $resourceType = DownloadHelper::LINK_TYPE_URL;
102 }
elseif (
$link->getLinkType() == DownloadHelper::LINK_TYPE_FILE) {
104 \
Magento\Downloadable\Helper\File::class
109 $resourceType = DownloadHelper::LINK_TYPE_FILE;
112 if (
$link->getSampleType() == DownloadHelper::LINK_TYPE_URL) {
114 $resourceType = DownloadHelper::LINK_TYPE_URL;
115 }
elseif (
$link->getSampleType() == DownloadHelper::LINK_TYPE_FILE) {
117 \
Magento\Downloadable\Helper\File::class
119 $this->
_getLink()->getBaseSamplePath(),
120 $link->getSampleFile()
122 $resourceType = DownloadHelper::LINK_TYPE_FILE;
126 $this->_processDownload(
$resource, $resourceType);
127 }
catch (\
Magento\Framework\Exception\LocalizedException $e) {
128 $this->messageManager->addError(
__(
'Something went wrong while getting the requested content.'));
elseif(isset( $params[ 'redirect_parent']))