Skip to content

Commit

Permalink
added missing batch assets command
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGrimmChester committed Dec 26, 2023
1 parent 5609a7e commit 6d790e0
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/Command/BatchImportAssetsCommand.php
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

View workflow job for this annotation

GitHub Actions / PHP 8.2 Symfony 5.4.*

Parameter #2 $string of function explode expects string, mixed given.

Check failure on line 36 in src/Command/BatchImportAssetsCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 Symfony 5.4.*

Parameter #2 $string of function explode expects string, mixed given.

Check failure on line 36 in src/Command/BatchImportAssetsCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 Symfony 6.2.*

Parameter #2 $string of function explode expects string, mixed given.

Check failure on line 36 in src/Command/BatchImportAssetsCommand.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 Symfony 6.2.*

Parameter #2 $string of function explode expects string, mixed given.

$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;
}
}

0 comments on commit 6d790e0

Please sign in to comment.