Skip to content

Commit

Permalink
magento/adobe-stock-integration#1724: Support batches processing for …
Browse files Browse the repository at this point in the history
…synchronization queue messages - implemented gallery synchronization functionality
  • Loading branch information
yolouiese committed Aug 18, 2020
1 parent a550e1e commit 29c3b26
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
13 changes: 7 additions & 6 deletions app/code/Magento/MediaContentSynchronization/Model/Consume.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Magento\MediaContentSynchronization\Model;

use Magento\Framework\Exception\LocalizedException;
use Magento\MediaContentApi\Api\Data\ContentIdentityInterface;
use Magento\MediaContentSynchronizationApi\Api\SynchronizeIdentitiesInterface;
use Magento\MediaContentSynchronizationApi\Api\SynchronizeInterface;

Expand Down Expand Up @@ -40,15 +41,15 @@ public function __construct(

/**
* Run media files synchronization.
* @param string[] $message
* @param string[] $identities
* @throws LocalizedException
*/
public function execute(array $message) : void
public function execute(array $identities) : void
{
$this->synchronize->execute();

if (!empty($message)) {
$this->synchronizeIdentities->execute($message);
if (!empty($identities)) {
$this->synchronizeIdentities->execute($identities);
} else {
$this->synchronize->execute();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ public function __construct(PublisherInterface $publisher)

/**
* Publish media content synchronization message to the message queue.
* @param array $contentIdentities
*/
public function execute() : void
public function execute(array $contentIdentities = []) : void
{
$this->publisher->publish(
self::TOPIC_MEDIA_CONTENT_SYNCHRONIZATION,
[self::TOPIC_MEDIA_CONTENT_SYNCHRONIZATION]
$contentIdentities
);
}
}
1 change: 1 addition & 0 deletions app/code/Magento/MediaContentSynchronization/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\MediaContentSynchronizationApi\Api\SynchronizeInterface" type="Magento\MediaContentSynchronization\Model\Synchronize"/>
<preference for="Magento\MediaContentSynchronizationApi\Api\SynchronizeIdentitiesInterface" type="Magento\MediaContentSynchronization\Model\SynchronizeIdentities"/>
<type name="Magento\Framework\Console\CommandListInterface">
<arguments>
<argument name="commands" xsi:type="array">
Expand Down
12 changes: 6 additions & 6 deletions app/code/Magento/MediaGallerySynchronization/Model/Consume.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public function __construct(

/**
* Run media files synchronization.
* @param string[] $message
* @param array $paths
* @throws LocalizedException
*/
public function execute(array $message) : void
public function execute(array $paths) : void
{
$this->synchronize->execute();

if (!empty($message)) {
$this->synchronizeFiles->execute($message);
if (!empty($paths)) {
$this->synchronizeFiles->execute($paths);
} else {
$this->synchronize->execute();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ public function __construct(PublisherInterface $publisher)

/**
* Publish media content synchronization message to the message queue.
* @param array $paths
*/
public function execute() : void
public function execute(array $paths = []) : void
{
$this->publisher->publish(
self::TOPIC_MEDIA_GALLERY_SYNCHRONIZATION,
[self::TOPIC_MEDIA_GALLERY_SYNCHRONIZATION]
$paths
);
}
}

0 comments on commit 29c3b26

Please sign in to comment.