Skip to content

Commit 6017858

Browse files
authored
ENGCOM-7954: Apply review suggestion to the media modules #29396
2 parents 4af7fc1 + 4e891cc commit 6017858

File tree

14 files changed

+47
-130
lines changed

14 files changed

+47
-130
lines changed

app/code/Magento/MediaContentSynchronizationApi/Api/SynchronizerInterface.php

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

app/code/Magento/MediaContentSynchronizationApi/Model/SynchronizerPool.php

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

88
namespace Magento\MediaContentSynchronizationApi\Model;
99

10-
use Magento\MediaContentSynchronizationApi\Api\SynchronizerInterface;
10+
use Magento\MediaContentSynchronizationApi\Api\SynchronizeInterface;
1111

1212
/**
1313
* A pool that handles content and assets synchronization.
@@ -18,20 +18,20 @@ class SynchronizerPool
1818
/**
1919
* Content with assets synchronizers
2020
*
21-
* @var SynchronizerInterface[]
21+
* @var SynchronizeInterface[]
2222
*/
2323
private $synchronizers;
2424

2525
/**
26-
* @param SynchronizerInterface[] $synchronizers
26+
* @param SynchronizeInterface[] $synchronizers
2727
*/
2828
public function __construct(
2929
array $synchronizers = []
3030
) {
3131
foreach ($synchronizers as $synchronizer) {
32-
if (!$synchronizer instanceof SynchronizerInterface) {
32+
if (!$synchronizer instanceof SynchronizeInterface) {
3333
throw new \InvalidArgumentException(
34-
get_class($synchronizer) . ' must implement ' . SynchronizerInterface::class
34+
get_class($synchronizer) . ' must implement ' . SynchronizeInterface::class
3535
);
3636
}
3737
}
@@ -42,7 +42,7 @@ public function __construct(
4242
/**
4343
* Get all synchronizers from the pool
4444
*
45-
* @return SynchronizerInterface[]
45+
* @return SynchronizeInterface[]
4646
*/
4747
public function get(): array
4848
{

app/code/Magento/MediaContentSynchronizationCatalog/Model/Synchronizer/Category.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory;
1111
use Magento\MediaContentApi\Api\UpdateContentAssetLinksInterface;
1212
use Magento\MediaContentApi\Model\GetEntityContentsInterface;
13-
use Magento\MediaContentSynchronizationApi\Api\SynchronizerInterface;
13+
use Magento\MediaContentSynchronizationApi\Api\SynchronizeInterface;
1414
use Magento\MediaGallerySynchronizationApi\Model\FetchBatchesInterface;
1515

1616
/**
1717
* Synchronize category content with assets
1818
*/
19-
class Category implements SynchronizerInterface
19+
class Category implements SynchronizeInterface
2020
{
2121
private const CONTENT_TYPE = 'catalog_category';
2222
private const TYPE = 'entityType';

app/code/Magento/MediaContentSynchronizationCatalog/Model/Synchronizer/Product.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory;
1111
use Magento\MediaContentApi\Api\UpdateContentAssetLinksInterface;
1212
use Magento\MediaContentApi\Model\GetEntityContentsInterface;
13-
use Magento\MediaContentSynchronizationApi\Api\SynchronizerInterface;
13+
use Magento\MediaContentSynchronizationApi\Api\SynchronizeInterface;
1414
use Magento\MediaGallerySynchronizationApi\Model\FetchBatchesInterface;
1515

1616
/**
1717
* Synchronize product content with assets
1818
*/
19-
class Product implements SynchronizerInterface
19+
class Product implements SynchronizeInterface
2020
{
2121
private const CONTENT_TYPE = 'catalog_product';
2222
private const TYPE = 'entityType';

app/code/Magento/MediaContentSynchronizationCms/Model/Synchronizer/Block.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99

1010
use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory;
1111
use Magento\MediaContentApi\Api\UpdateContentAssetLinksInterface;
12-
use Magento\MediaContentSynchronizationApi\Api\SynchronizerInterface;
12+
use Magento\MediaContentSynchronizationApi\Api\SynchronizeInterface;
1313
use Magento\MediaGallerySynchronizationApi\Model\FetchBatchesInterface;
1414

1515
/**
1616
* Synchronize block content with assets
1717
*/
18-
class Block implements SynchronizerInterface
18+
class Block implements SynchronizeInterface
1919
{
2020
private const CONTENT_TYPE = 'cms_block';
2121
private const TYPE = 'entityType';

app/code/Magento/MediaContentSynchronizationCms/Model/Synchronizer/Page.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99

1010
use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory;
1111
use Magento\MediaContentApi\Api\UpdateContentAssetLinksInterface;
12-
use Magento\MediaContentSynchronizationApi\Api\SynchronizerInterface;
12+
use Magento\MediaContentSynchronizationApi\Api\SynchronizeInterface;
1313
use Magento\MediaGallerySynchronizationApi\Model\FetchBatchesInterface;
1414

1515
/**
1616
* Synchronize page content with assets
1717
*/
18-
class Page implements SynchronizerInterface
18+
class Page implements SynchronizeInterface
1919
{
2020
private const CONTENT_TYPE = 'cms_page';
2121
private const TYPE = 'entityType';

app/code/Magento/MediaGalleryMetadata/Model/File/ExtractMetadata.php

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,31 +66,12 @@ public function __construct(
6666
public function execute(string $path): MetadataInterface
6767
{
6868
try {
69-
return $this->extractMetadata($path);
69+
return $this->readSegments($this->fileReader->execute($path));
7070
} catch (\Exception $exception) {
7171
return $this->metadataFactory->create();
7272
}
7373
}
7474

75-
/**
76-
* Extract metadata from file
77-
*
78-
* @param string $path
79-
* @return MetadataInterface
80-
*/
81-
private function extractMetadata(string $path): MetadataInterface
82-
{
83-
try {
84-
$file = $this->fileReader->execute($path);
85-
} catch (\Exception $exception) {
86-
throw new LocalizedException(
87-
__('Could not parse the image file for metadata: %path', ['path' => $path])
88-
);
89-
}
90-
91-
return $this->readSegments($file);
92-
}
93-
9475
/**
9576
* Read file segments by given segmentReader
9677
*

app/code/Magento/MediaGallerySynchronization/Model/CreateAssetFromFile.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory;
1818
use Magento\MediaGalleryMetadataApi\Api\ExtractMetadataInterface;
1919
use Magento\MediaGallerySynchronization\Model\Filesystem\SplFileInfoFactory;
20-
use Magento\MediaGallerySynchronizationApi\Model\GetContentHashInterface;
20+
use Magento\MediaGallerySynchronization\Model\GetContentHash;
2121

2222
/**
2323
* Create media asset object based on the file information
@@ -50,7 +50,7 @@ class CreateAssetFromFile
5050
private $assetFactory;
5151

5252
/**
53-
* @var GetContentHashInterface
53+
* @var GetContentHash
5454
*/
5555
private $getContentHash;
5656

@@ -69,7 +69,7 @@ class CreateAssetFromFile
6969
* @param File $driver
7070
* @param TimezoneInterface $date
7171
* @param AssetInterfaceFactory $assetFactory
72-
* @param GetContentHashInterface $getContentHash
72+
* @param GetContentHash $getContentHash
7373
* @param ExtractMetadataInterface $extractMetadata
7474
* @param SplFileInfoFactory $splFileInfoFactory
7575
*/
@@ -78,7 +78,7 @@ public function __construct(
7878
File $driver,
7979
TimezoneInterface $date,
8080
AssetInterfaceFactory $assetFactory,
81-
GetContentHashInterface $getContentHash,
81+
GetContentHash $getContentHash,
8282
ExtractMetadataInterface $extractMetadata,
8383
SplFileInfoFactory $splFileInfoFactory
8484
) {

app/code/Magento/MediaGallerySynchronization/Model/GetContentHash.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77

88
namespace Magento\MediaGallerySynchronization\Model;
99

10-
use Magento\MediaGallerySynchronizationApi\Model\GetContentHashInterface;
11-
1210
/**
1311
* Get hashed value of image content.
1412
*/
15-
class GetContentHash implements GetContentHashInterface
13+
class GetContentHash
1614
{
1715
/**
1816
* Return the hash value of the given filepath.

app/code/Magento/MediaGallerySynchronization/Test/Integration/Model/GetContentHashTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99

1010
use Magento\Framework\Exception\FileSystemException;
1111
use Magento\Framework\Filesystem\DriverInterface;
12-
use Magento\MediaGallerySynchronizationApi\Model\GetContentHashInterface;
12+
use Magento\MediaGallerySynchronization\Model\GetContentHash;
1313
use Magento\TestFramework\Helper\Bootstrap;
1414
use PHPUnit\Framework\TestCase;
1515

1616
/**
17-
* Test for GetContentHashInterface.
17+
* Test for GetContentHash.
1818
*/
1919
class GetContentHashTest extends TestCase
2020
{
2121
/**
22-
* @var GetContentHashInterface
22+
* @var GetContentHash
2323
*/
2424
private $getContentHash;
2525

@@ -33,12 +33,12 @@ class GetContentHashTest extends TestCase
3333
*/
3434
protected function setUp(): void
3535
{
36-
$this->getContentHash = Bootstrap::getObjectManager()->get(GetContentHashInterface::class);
36+
$this->getContentHash = Bootstrap::getObjectManager()->get(GetContentHash::class);
3737
$this->driver = Bootstrap::getObjectManager()->get(DriverInterface::class);
3838
}
3939

4040
/**
41-
* Test for GetContentHashInterface::execute
41+
* Test for GetContentHash::execute
4242
*
4343
* @dataProvider filesProvider
4444
* @param string $firstFile

0 commit comments

Comments
 (0)