Skip to content

Commit

Permalink
#1578: Move MediaGallery related modules to Magento core
Browse files Browse the repository at this point in the history
- code review fixes
  • Loading branch information
lenaorobei committed Jul 20, 2020
1 parent deac2a2 commit 64c2af4
Show file tree
Hide file tree
Showing 30 changed files with 33 additions and 66 deletions.
16 changes: 0 additions & 16 deletions AdobeStockImageAdminUi/etc/config.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* Media content synchronization queue consumer.
*/
class Consume
class Consumer
{
/**
* @var SynchronizeInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

use Magento\MediaContentSynchronization\Model\Publish;
use Magento\Framework\Exception\LocalizedException;
use Magento\MediaGallerySynchronization\Model\Consume;
use Magento\MediaGallerySynchronization\Model\Consumer;

/**
* Run media content synchronization after the media files consumer finish files synchronization.
Expand All @@ -32,10 +32,10 @@ public function __construct(Publish $publish)
/**
* Publish content synchronization request message to the queue.
*
* @param Consume $subject
* @param Consumer $subject
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterExecute(Consume $subject): void
public function afterExecute(Consumer $subject): void
{
$this->publish->execute();
}
Expand Down
2 changes: 1 addition & 1 deletion MediaContentSynchronization/etc/communication.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
xsi:noNamespaceSchemaLocation="urn:magento:framework:Communication/etc/communication.xsd">
<topic name="media.content.synchronization" is_synchronous="false" request="string[]">
<handler name="media.content.synchronization.handler"
type="Magento\MediaContentSynchronization\Model\Consume" method="execute"/>
type="Magento\MediaContentSynchronization\Model\Consumer" method="execute"/>
</topic>
</config>
2 changes: 1 addition & 1 deletion MediaContentSynchronization/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</argument>
</arguments>
</type>
<type name="Magento\MediaGallerySynchronization\Model\Consume">
<type name="Magento\MediaGallerySynchronization\Model\Consumer">
<plugin name="synchronize_media_content"
type="Magento\MediaContentSynchronization\Plugin\SynchronizeMediaContent"/>
</type>
Expand Down
2 changes: 1 addition & 1 deletion MediaContentSynchronization/etc/queue_consumer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/consumer.xsd">
<consumer name="media.content.synchronization" queue="media.content.synchronization"
connection="db" handler="Magento\MediaContentSynchronization\Model\Consume::execute"/>
connection="db" handler="Magento\MediaContentSynchronization\Model\Consumer::execute"/>
</config>
1 change: 0 additions & 1 deletion MediaGalleryMetadataApi/Api/ExtractMetadataInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Magento\MediaGalleryMetadataApi\Api;

use Magento\Framework\Exception\LocalizedException;
use Magento\MediaGalleryMetadataApi\Api\Data\MetadataInterface;

/**
Expand Down
2 changes: 1 addition & 1 deletion MediaGalleryMetadataApi/Model/AddMetadataComposite.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* Metadata writer pool
*/
class AddMetadataComposite
class AddMetadataComposite implements AddMetadataInterface
{
/**
* @var AddMetadataInterface[]
Expand Down
2 changes: 1 addition & 1 deletion MediaGalleryRenditions/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Magento\MediaGalleryRenditions\Model;

use Magento\MediaGalleryRenditionsApi\Model\ConfigInterface;
use Magento\MediaGalleryRenditionsApi\Api\ConfigInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

declare(strict_types=1);

namespace Magento\MediaGalleryRenditionsApi\Model;
namespace Magento\MediaGalleryRenditionsApi\Api;

/**
* Class responsible for providing API access to Media Gallery Renditions system configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* Media gallery image synchronization queue consumer.
*/
class Consume
class Consumer
{
/**
* @var SynchronizeInterface
Expand Down
2 changes: 1 addition & 1 deletion MediaGallerySynchronization/etc/communication.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
xsi:noNamespaceSchemaLocation="urn:magento:framework:Communication/etc/communication.xsd">
<topic name="media.gallery.synchronization" is_synchronous="false" request="string[]">
<handler name="media.gallery.synchronization.handler"
type="Magento\MediaGallerySynchronization\Model\Consume" method="execute"/>
type="Magento\MediaGallerySynchronization\Model\Consumer" method="execute"/>
</topic>
</config>
2 changes: 1 addition & 1 deletion MediaGallerySynchronization/etc/queue_consumer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/consumer.xsd">
<consumer name="media.gallery.synchronization" queue="media.gallery.synchronization"
connection="db" handler="Magento\MediaGallerySynchronization\Model\Consume::execute"/>
connection="db" handler="Magento\MediaGallerySynchronization\Model\Consumer::execute"/>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

namespace Magento\MediaGallerySynchronizationApi\Model;

use Magento\Framework\Exception\LocalizedException;

/**
* Fetch data from database in batches
*/
Expand Down
15 changes: 6 additions & 9 deletions MediaGalleryUi/Controller/Adminhtml/Image/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,14 @@ public function execute()
$assets = $this->getAssetsByIds->execute($imageIds);
$this->deleteImage->execute($assets);
$responseCode = self::HTTP_OK;
$message = count($imageIds) > 1 ?
'assets have been' :
' asset "' . current($assets)->getTitle() . '" has been';
if (count($imageIds) === 1) {
$message = sprintf('The asset %s has been successfully deleted', current($assets)->getTitle());
} else {
$message = 'Assets have been successfully deleted';
}
$responseContent = [
'success' => true,
'message' => __(
'The %message successfully deleted',
[
'message' => $message
]
),
'message' => __($message),
];
} catch (LocalizedException $exception) {
$responseCode = self::HTTP_BAD_REQUEST;
Expand Down
2 changes: 0 additions & 2 deletions MediaGalleryUi/Model/AssetDetailsProvider/CreatedAt.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

namespace Magento\MediaGalleryUi\Model\AssetDetailsProvider;

use Magento\Framework\Exception\IntegrationException;
use Magento\MediaContentApi\Api\GetContentByAssetIdsInterface;
use Magento\MediaGalleryApi\Api\Data\AssetInterface;
use Magento\MediaGalleryUi\Model\AssetDetailsProviderInterface;

Expand Down
1 change: 0 additions & 1 deletion MediaGalleryUi/Model/AssetDetailsProvider/Height.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace Magento\MediaGalleryUi\Model\AssetDetailsProvider;

use Magento\Framework\Exception\IntegrationException;
use Magento\MediaContentApi\Api\GetContentByAssetIdsInterface;
use Magento\MediaGalleryApi\Api\Data\AssetInterface;
use Magento\MediaGalleryUi\Model\AssetDetailsProviderInterface;

Expand Down
1 change: 0 additions & 1 deletion MediaGalleryUi/Model/AssetDetailsProvider/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace Magento\MediaGalleryUi\Model\AssetDetailsProvider;

use Magento\Framework\Exception\IntegrationException;
use Magento\MediaContentApi\Api\GetContentByAssetIdsInterface;
use Magento\MediaGalleryApi\Api\Data\AssetInterface;
use Magento\MediaGalleryUi\Model\AssetDetailsProviderInterface;

Expand Down
1 change: 0 additions & 1 deletion MediaGalleryUi/Model/AssetDetailsProvider/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace Magento\MediaGalleryUi\Model\AssetDetailsProvider;

use Magento\Framework\Exception\IntegrationException;
use Magento\MediaContentApi\Api\GetContentByAssetIdsInterface;
use Magento\MediaGalleryApi\Api\Data\AssetInterface;
use Magento\MediaGalleryUi\Model\AssetDetailsProviderInterface;

Expand Down
2 changes: 0 additions & 2 deletions MediaGalleryUi/Model/AssetDetailsProvider/UpdatedAt.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

namespace Magento\MediaGalleryUi\Model\AssetDetailsProvider;

use Magento\Framework\Exception\IntegrationException;
use Magento\MediaContentApi\Api\GetContentByAssetIdsInterface;
use Magento\MediaGalleryApi\Api\Data\AssetInterface;
use Magento\MediaGalleryUi\Model\AssetDetailsProviderInterface;

Expand Down
8 changes: 2 additions & 6 deletions MediaGalleryUi/Model/AssetDetailsProvider/UsedIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,11 @@ private function getUsedIn(int $assetId): array
foreach ($contentIdentities as $contentIdentity) {
$entityId = $contentIdentity->getEntityId();
$type = $this->contentTypes[$contentIdentity->getEntityType()] ?? $contentIdentity->getEntityType();

if (!isset($entityIds[$type])) {
$usedIn[$type] = 1;
} elseif ($entityIds[$type]['entity_id'] !== $entityId) {
if (isset($usedIn[$type])) {
$usedIn[$type] +=1;
} else {
$usedIn[$type] = $usedIn[$type]+1;
}
++$usedIn[$type];
}
$entityIds[$type]['entity_id'] = $entityId;
}
Expand Down
1 change: 0 additions & 1 deletion MediaGalleryUi/Model/AssetDetailsProvider/Width.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace Magento\MediaGalleryUi\Model\AssetDetailsProvider;

use Magento\Framework\Exception\IntegrationException;
use Magento\MediaContentApi\Api\GetContentByAssetIdsInterface;
use Magento\MediaGalleryApi\Api\Data\AssetInterface;
use Magento\MediaGalleryUi\Model\AssetDetailsProviderInterface;

Expand Down
5 changes: 2 additions & 3 deletions MediaGalleryUi/Model/DeleteImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ public function __construct(
}

/**
* Delete asset image physically from file storage and from data storage via MediaGallery plugin.
*
* @see \Magento\MediaGallery\Plugin\Wysiwyg\Images\Storage
* Delete asset image physically from file storage and from data storage.
*
* @param AssetInterface[] $assets
* @throws LocalizedException
*/
public function execute(array $assets): void
{
Expand Down
1 change: 0 additions & 1 deletion MediaGalleryUi/Model/Listing/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Magento\Framework\App\RequestInterface;
use Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory;
use Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider as UiComponentDataProvider;
use Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult;
use Magento\MediaGalleryUi\Ui\Component\Listing\Provider;

/**
Expand Down
3 changes: 3 additions & 0 deletions MediaGalleryUi/Plugin/ResizeSyncedFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use Magento\MediaGallerySynchronization\Model\SynchronizeFiles;
use Magento\Cms\Model\Wysiwyg\Images\Storage;

/**
* Create resizes files that were synced
*/
class ResizeSyncedFiles
{
/**
Expand Down
7 changes: 4 additions & 3 deletions MediaGalleryUi/Ui/Component/ImageUploaderStandAlone.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ public function prepare(): void
array_replace_recursive(
(array) $this->getData('config'),
[
// phpcs:disable Magento2.Files.LineLength, Generic.Files.LineLength
'actionsPath' => 'standalone_media_gallery_listing.standalone_media_gallery_listing.media_gallery_columns.thumbnail_url',
'directoriesPath' => 'standalone_media_gallery_listing.standalone_media_gallery_listing.media_gallery_directories',
'actionsPath' => 'standalone_media_gallery_listing.standalone_media_gallery_listing' .
'.media_gallery_columns.thumbnail_url',
'directoriesPath' => 'standalone_media_gallery_listing.standalone_media_gallery_listing' .
'.media_gallery_directories',
'messagesPath' => 'standalone_media_gallery_listing.standalone_media_gallery_listing.messages'
]
)
Expand Down
1 change: 0 additions & 1 deletion MediaGalleryUi/Ui/Component/Listing/Columns/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Store\Model\Store;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Ui\Component\Listing\Columns\Column;
use Magento\Cms\Helper\Wysiwyg\Images;
Expand Down
2 changes: 1 addition & 1 deletion MediaGalleryUi/Ui/Component/Listing/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function getData()
$data[$key]['content_type'] = strtoupper(str_replace('image/', '', $asset['content_type']));
$data[$key]['preview_url'] = $asset['path'];
$data[$key]['keywords'] = isset($keywords[$asset['id']]) ? implode(",", $keywords[$asset['id']]) : '';
$data[$key]['source'] = empty($asset['source']) ? 'Local' : $asset['source'];
$data[$key]['source'] = empty($asset['source']) ? __('Local') : $asset['source'];
}
return $data;
}
Expand Down
2 changes: 1 addition & 1 deletion MediaGalleryUi/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<default>
<system>
<media_gallery>
<enabled>1</enabled>
<enabled>0</enabled>
</media_gallery>
</system>
</default>
Expand Down
2 changes: 1 addition & 1 deletion MediaGalleryUiApi/Api/ConfigInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
interface ConfigInterface
{
/**
* Check if masonry grid UI is enabled for Magento media gallery
* Check if grid UI is enabled for Magento media gallery
*
* @return bool
*/
Expand Down

0 comments on commit 64c2af4

Please sign in to comment.