-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5609a7e
commit 6d790e0
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Synolia\SyliusAkeneoPlugin\Command; | ||
|
||
use Psr\Log\LoggerInterface; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Synolia\SyliusAkeneoPlugin\Client\ClientFactoryInterface; | ||
use Synolia\SyliusAkeneoPlugin\Payload\Asset\AssetPayload; | ||
use Synolia\SyliusAkeneoPlugin\Task\Asset\BatchAssetTask; | ||
|
||
final class BatchImportAssetsCommand extends AbstractBatchCommand | ||
{ | ||
protected static $defaultDescription = 'Import batch assets ids from Akeneo PIM.'; | ||
|
||
/** @var string */ | ||
public static $defaultName = 'akeneo:batch:assets'; | ||
|
||
public function __construct( | ||
private ClientFactoryInterface $clientFactory, | ||
private LoggerInterface $logger, | ||
private BatchAssetTask $batchAssetTask, | ||
) { | ||
parent::__construct(self::$defaultName); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function execute( | ||
InputInterface $input, | ||
OutputInterface $output, | ||
) { | ||
$ids = explode(',', $input->getArgument('ids')); | ||
Check failure on line 36 in src/Command/BatchImportAssetsCommand.php
|
||
|
||
$this->logger->notice('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]); | ||
$this->logger->debug(self::$defaultName, ['batched_ids' => $ids]); | ||
|
||
$batchPayload = new AssetPayload($this->clientFactory->createFromApiCredentials()); | ||
$batchPayload->setIds($ids); | ||
|
||
$this->batchAssetTask->__invoke($batchPayload); | ||
|
||
return 0; | ||
} | ||
} |