Skip to content

Commit 837dd9d

Browse files
author
Viktor Kopin
committed
magento/adobe-stock-integration#1806: remove unnecessary interface, after review fixes
1 parent 1db2872 commit 837dd9d

File tree

6 files changed

+17
-53
lines changed

6 files changed

+17
-53
lines changed

app/code/Magento/MediaGalleryUi/Controller/Adminhtml/Image/OnInsert.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Magento\Framework\App\Action\HttpPostActionInterface;
1414
use Magento\Framework\Controller\Result\JsonFactory;
1515
use Magento\Framework\Controller\ResultInterface;
16-
use Magento\MediaGalleryUiApi\Api\GetInsertImageDataInterface;
16+
use Magento\MediaGalleryUi\Model\InsertImageData\GetInsertImageData;
1717

1818
/**
1919
* OnInsert action returns on insert image details
@@ -31,19 +31,19 @@ class OnInsert extends Action implements HttpPostActionInterface
3131
private $resultJsonFactory;
3232

3333
/**
34-
* @var GetInsertImageDataInterface
34+
* @var GetInsertImageData
3535
*/
3636
private $getInsertImageData;
3737

3838
/**
3939
* @param Context $context
4040
* @param JsonFactory $resultJsonFactory
41-
* @param GetInsertImageDataInterface|null $getInsertImageData
41+
* @param GetInsertImageData $getInsertImageData
4242
*/
4343
public function __construct(
4444
Context $context,
4545
JsonFactory $resultJsonFactory,
46-
GetInsertImageDataInterface $getInsertImageData
46+
GetInsertImageData $getInsertImageData
4747
) {
4848
parent::__construct($context);
4949
$this->resultJsonFactory = $resultJsonFactory;

app/code/Magento/MediaGalleryUi/Model/InsertImageData.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
namespace Magento\MediaGalleryUi\Model;
1010

11-
use Magento\MediaGalleryUiApi\Api\Data\InsertImageDataInterface;
12-
use Magento\MediaGalleryUiApi\Api\InsertImageDataExtensionInterface;
11+
use Magento\MediaGalleryUi\Model\InsertImageDataExtensionInterface;
1312

1413
/**
1514
* Class responsible to provide insert image details
@@ -83,7 +82,7 @@ public function getType(): string
8382
/**
8483
* Get extension attributes
8584
*
86-
* @return ?\Magento\MediaGalleryUiApi\Api\InsertImageDataExtensionInterface;|null
85+
* @return \Magento\MediaGalleryUi\Model\InsertImageDataExtensionInterface|null
8786
*/
8887
public function getExtensionAttributes(): ?InsertImageDataExtensionInterface
8988
{
@@ -93,10 +92,10 @@ public function getExtensionAttributes(): ?InsertImageDataExtensionInterface
9392
/**
9493
* Set extension attributes
9594
*
96-
* @param ?\Magento\MediaGalleryUiApi\Api\InsertImageDataExtensionInterface;|null $extensionAttributes
95+
* @param \Magento\MediaGalleryUi\Model\InsertImageDataExtensionInterface $extensionAttributes
9796
* @return void
9897
*/
99-
public function setExtensionAttributes(?InsertImageDataExtensionInterface $extensionAttributes): void
98+
public function setExtensionAttributes(InsertImageDataExtensionInterface $extensionAttributes): void
10099
{
101100
$this->extensionAttributes = $extensionAttributes;
102101
}

app/code/Magento/MediaGalleryUi/Model/InsertImageData/GetInsertImageData.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
use Magento\Framework\Filesystem;
1515
use Magento\Framework\Filesystem\Directory\ReadInterface;
1616
use Magento\MediaGalleryUi\Model\InsertImageDataFactory;
17-
use Magento\MediaGalleryUiApi\Api\Data\InsertImageDataInterface;
18-
use Magento\MediaGalleryUiApi\Api\GetInsertImageDataInterface;
17+
use Magento\MediaGalleryUi\Model\InsertImageDataInterface;
1918

20-
class GetInsertImageData implements GetInsertImageDataInterface
19+
class GetInsertImageData
2120
{
2221
/**
2322
* @var ReadInterface
@@ -115,9 +114,9 @@ private function getSize(string $path): int
115114
*/
116115
public function getType(string $path): string
117116
{
118-
$absoluteFilePath = $this->getPubDirectory()->getAbsolutePath($path);
117+
$fileExist = $this->getPubDirectory()->isExist($path);
119118

120-
return $this->getPubDirectory()->isExist($path) ? $this->mime->getMimeType($absoluteFilePath) : '';
119+
return $fileExist ? $this->mime->getMimeType($this->getPubDirectory()->getAbsolutePath($path)) : '';
121120
}
122121

123122
/**

app/code/Magento/MediaGalleryUiApi/Api/Data/InsertImageDataInterface.php renamed to app/code/Magento/MediaGalleryUi/Model/InsertImageDataInterface.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
declare(strict_types=1);
88

9-
namespace Magento\MediaGalleryUiApi\Api\Data;
9+
namespace Magento\MediaGalleryUi\Model;
1010

1111
use Magento\Framework\Api\ExtensibleDataInterface;
1212

@@ -39,17 +39,17 @@ public function getType(): string;
3939
/**
4040
* Get extension attributes
4141
*
42-
* @return \Magento\MediaGalleryUiApi\Api\InsertImageDataExtensionInterface|null
42+
* @return \Magento\MediaGalleryUi\Model\InsertImageDataExtensionInterface|null
4343
*/
44-
public function getExtensionAttributes(): ?\Magento\MediaGalleryUiApi\Api\InsertImageDataExtensionInterface;
44+
public function getExtensionAttributes(): ?\Magento\MediaGalleryUi\Model\InsertImageDataExtensionInterface;
4545

4646
/**
4747
* Set extension attributes
4848
*
49-
* @param \Magento\MediaGalleryUiApi\Api\InsertImageDataExtensionInterface|null $extensionAttributes
49+
* @param \Magento\MediaGalleryUi\Model\InsertImageDataExtensionInterface $extensionAttributes
5050
* @return void
5151
*/
5252
public function setExtensionAttributes(
53-
?\Magento\MediaGalleryUiApi\Api\InsertImageDataExtensionInterface $extensionAttributes
53+
\Magento\MediaGalleryUi\Model\InsertImageDataExtensionInterface $extensionAttributes
5454
): void;
5555
}

app/code/Magento/MediaGalleryUi/etc/di.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
99
<preference for="Magento\MediaGalleryUiApi\Api\ConfigInterface" type="Magento\MediaGalleryUi\Model\Config"/>
10-
<preference for="Magento\MediaGalleryUiApi\Api\GetInsertImageDataInterface" type="\Magento\MediaGalleryUi\Model\InsertImageData\GetInsertImageData"/>
1110
<preference for="Magento\MediaGalleryUiApi\Api\Data\InsertImageDataInterface" type="\Magento\MediaGalleryUi\Model\InsertImageData"/>
1211
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
1312
<arguments>

app/code/Magento/MediaGalleryUiApi/Api/GetInsertImageDataInterface.php

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)