Skip to content

Commit

Permalink
Removed deprecated and added property scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGrimmChester committed Nov 28, 2024
1 parent a9f672c commit eef385c
Show file tree
Hide file tree
Showing 33 changed files with 193 additions and 183 deletions.
3 changes: 3 additions & 0 deletions ruleset/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ parameters:
- '#Call to an undefined method League\\Pipeline\\PipelineInterface\:\:process\(\).#'
- '#Method Doctrine\\Persistence\\ObjectRepository<object>\:\:findOneBy\(\) invoked with 2 parameters, 1 required.#'
- "#^Call to an undefined method Symfony\\\\Component\\\\HttpFoundation\\\\Session\\\\SessionInterface\\:\\:getFlashBag\\(\\)\\.$#"
-
message: '#Property [a-zA-Z0-9\\_]+::\$pipelineFactory is never read, only written.#'
path: ../src/Command/*
4 changes: 0 additions & 4 deletions src/Command/AbstractBatchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@

abstract class AbstractBatchCommand extends Command
{
/** @var string The default command description */
protected static $defaultDescription = '';

protected function configure(): void
{
$this->setDescription(static::$defaultDescription);
$this->addArgument('ids', InputArgument::REQUIRED, 'Comma separated list of ids');
$this->setHidden(true);
}
Expand Down
11 changes: 3 additions & 8 deletions src/Command/AbstractImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,19 @@ abstract class AbstractImportCommand extends Command
{
use LockableTrait;

/** @var string The default command description */
protected static $defaultDescription = '';

protected PipelineInterface $pipeline;

public function __construct(
protected LoggerInterface $akeneoLogger,
protected PayloadFactoryInterface $payloadFactory,
private PipelineFactoryInterface $pipelineFactory,
string $name = null,
) {
parent::__construct($name);
parent::__construct();
}

protected function configure(): void
{
$this
->setDescription(static::$defaultDescription)
->addOption('continue')
->addOption('parallel', 'p', InputOption::VALUE_NONE, 'Allow parallel task processing')
->addOption('disable-batch', 'd', InputOption::VALUE_NONE, 'Disable batch processing')
Expand All @@ -57,14 +52,14 @@ protected function preExecute(): void
throw new CommandLockedException(Messages::commandAlreadyRunning());
}

$this->akeneoLogger->notice(static::$defaultName ?? '');
$this->akeneoLogger->notice($this->getName() ?? '');

$this->pipeline = $this->pipelineFactory->create();
}

protected function postExecute(): void
{
$this->akeneoLogger->notice(Messages::endOfCommand(static::$defaultName ?? ''));
$this->akeneoLogger->notice(Messages::endOfCommand($this->getName() ?? ''));
$this->release();
}
}
19 changes: 10 additions & 9 deletions src/Command/BatchImportAssetsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@
namespace Synolia\SyliusAkeneoPlugin\Command;

use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
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;
use Webmozart\Assert\Assert;

#[AsCommand(
name: 'akeneo:batch:assets',
description: 'Import batch assets ids from Akeneo PIM.',
)]
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 $akeneoLogger,
private ClientFactoryInterface $clientFactory,
private BatchAssetTask $batchAssetTask,
) {
parent::__construct(self::$defaultName);
parent::__construct();
}

/**
Expand All @@ -38,13 +39,13 @@ protected function execute(
$ids = explode(',', $input->getArgument('ids'));

$this->akeneoLogger->notice('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug(self::$defaultName, ['batched_ids' => $ids]);
$this->akeneoLogger->debug($this->getName() ?? '', ['batched_ids' => $ids]);

$batchPayload = new AssetPayload($this->clientFactory->createFromApiCredentials());
$batchPayload->setIds($ids);

$this->batchAssetTask->__invoke($batchPayload);

return 0;
return Command::SUCCESS;
}
}
19 changes: 10 additions & 9 deletions src/Command/BatchImportAssociationTypesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@
namespace Synolia\SyliusAkeneoPlugin\Command;

use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Synolia\SyliusAkeneoPlugin\Client\ClientFactoryInterface;
use Synolia\SyliusAkeneoPlugin\Payload\Association\AssociationTypePayload;
use Synolia\SyliusAkeneoPlugin\Task\AssociationType\BatchAssociationTypesTask;
use Webmozart\Assert\Assert;

#[AsCommand(
name: 'akeneo:batch:association-types',
description: 'Import batch association type ids from Akeneo PIM.',
)]
final class BatchImportAssociationTypesCommand extends AbstractBatchCommand
{
protected static $defaultDescription = 'Import batch association type ids from Akeneo PIM.';

/** @var string */
public static $defaultName = 'akeneo:batch:association-types';

public function __construct(
private ClientFactoryInterface $clientFactory,
private LoggerInterface $akeneoLogger,
private ClientFactoryInterface $clientFactory,
private BatchAssociationTypesTask $batchAssociationTypesTask,
) {
parent::__construct(self::$defaultName);
parent::__construct();
}

/**
Expand All @@ -38,13 +39,13 @@ protected function execute(
$ids = explode(',', $input->getArgument('ids'));

$this->akeneoLogger->notice('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug(self::$defaultName, ['batched_ids' => $ids]);
$this->akeneoLogger->debug($this->getName() ?? '', ['batched_ids' => $ids]);

$batchPayload = new AssociationTypePayload($this->clientFactory->createFromApiCredentials());
$batchPayload->setIds($ids);

$this->batchAssociationTypesTask->__invoke($batchPayload);

return 0;
return Command::SUCCESS;
}
}
19 changes: 10 additions & 9 deletions src/Command/BatchImportAttributesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@
namespace Synolia\SyliusAkeneoPlugin\Command;

use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Synolia\SyliusAkeneoPlugin\Client\ClientFactoryInterface;
use Synolia\SyliusAkeneoPlugin\Payload\Attribute\AttributePayload;
use Synolia\SyliusAkeneoPlugin\Task\Attribute\BatchAttributesTask;
use Webmozart\Assert\Assert;

#[AsCommand(
name: 'akeneo:batch:attributes',
description: 'Import batch attribute ids from Akeneo PIM.',
)]
final class BatchImportAttributesCommand extends AbstractBatchCommand
{
protected static $defaultDescription = 'Import batch attribute ids from Akeneo PIM.';

/** @var string */
protected static $defaultName = 'akeneo:batch:attributes';

public function __construct(
private ClientFactoryInterface $clientFactory,
private LoggerInterface $akeneoLogger,
private ClientFactoryInterface $clientFactory,
private BatchAttributesTask $attributesTask,
) {
parent::__construct(self::$defaultName);
parent::__construct();
}

/**
Expand All @@ -38,13 +39,13 @@ protected function execute(
$ids = explode(',', $input->getArgument('ids'));

$this->akeneoLogger->notice('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug(self::$defaultName, ['batched_ids' => $ids]);
$this->akeneoLogger->debug($this->getName() ?? '', ['batched_ids' => $ids]);

$attributePayload = new AttributePayload($this->clientFactory->createFromApiCredentials());
$attributePayload->setIds($ids);

$this->attributesTask->__invoke($attributePayload);

return 0;
return Command::SUCCESS;
}
}
19 changes: 10 additions & 9 deletions src/Command/BatchImportCategoriesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@
namespace Synolia\SyliusAkeneoPlugin\Command;

use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Synolia\SyliusAkeneoPlugin\Client\ClientFactoryInterface;
use Synolia\SyliusAkeneoPlugin\Payload\Category\CategoryPayload;
use Synolia\SyliusAkeneoPlugin\Task\Category\BatchCategoriesTask;
use Webmozart\Assert\Assert;

#[AsCommand(
name: 'akeneo:batch:categories',
description: 'Import batch categories ids from Akeneo PIM.',
)]
final class BatchImportCategoriesCommand extends AbstractBatchCommand
{
protected static $defaultDescription = 'Import batch categories ids from Akeneo PIM.';

/** @var string */
protected static $defaultName = 'akeneo:batch:categories';

public function __construct(
private ClientFactoryInterface $clientFactory,
private LoggerInterface $akeneoLogger,
private ClientFactoryInterface $clientFactory,
private BatchCategoriesTask $task,
) {
parent::__construct(self::$defaultName);
parent::__construct();
}

/**
Expand All @@ -38,13 +39,13 @@ protected function execute(
$ids = explode(',', $input->getArgument('ids'));

$this->akeneoLogger->notice('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug(self::$defaultName, ['batched_ids' => $ids]);
$this->akeneoLogger->debug($this->getName() ?? '', ['batched_ids' => $ids]);

$payload = new CategoryPayload($this->clientFactory->createFromApiCredentials());
$payload->setIds($ids);

$this->task->__invoke($payload);

return 0;
return Command::SUCCESS;
}
}
19 changes: 10 additions & 9 deletions src/Command/BatchImportProductModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@
namespace Synolia\SyliusAkeneoPlugin\Command;

use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Synolia\SyliusAkeneoPlugin\Client\ClientFactoryInterface;
use Synolia\SyliusAkeneoPlugin\Payload\ProductModel\ProductModelPayload;
use Synolia\SyliusAkeneoPlugin\Task\ProductModel\BatchProductModelTask;
use Webmozart\Assert\Assert;

#[AsCommand(
name: 'akeneo:batch:product-models',
description: 'Import batch product model ids from Akeneo PIM.',
)]
final class BatchImportProductModelsCommand extends AbstractBatchCommand
{
protected static $defaultDescription = 'Import batch product model ids from Akeneo PIM.';

/** @var string */
protected static $defaultName = 'akeneo:batch:product-models';

public function __construct(
private LoggerInterface $akeneoLogger,
private ClientFactoryInterface $clientFactory,
private BatchProductModelTask $batchProductModelTask,
private LoggerInterface $akeneoLogger,
) {
parent::__construct(self::$defaultName);
parent::__construct();
}

/**
Expand All @@ -38,13 +39,13 @@ protected function execute(
$ids = explode(',', $input->getArgument('ids'));

$this->akeneoLogger->notice('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug(self::$defaultName, ['batched_ids' => $ids]);
$this->akeneoLogger->debug($this->getName() ?? '', ['batched_ids' => $ids]);

$productModelPayload = new ProductModelPayload($this->clientFactory->createFromApiCredentials());
$productModelPayload->setIds($ids);

$this->batchProductModelTask->__invoke($productModelPayload);

return 0;
return Command::SUCCESS;
}
}
19 changes: 10 additions & 9 deletions src/Command/BatchImportProductsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@
namespace Synolia\SyliusAkeneoPlugin\Command;

use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Synolia\SyliusAkeneoPlugin\Client\ClientFactoryInterface;
use Synolia\SyliusAkeneoPlugin\Payload\Product\ProductPayload;
use Synolia\SyliusAkeneoPlugin\Task\Product\BatchProductsTask;
use Webmozart\Assert\Assert;

#[AsCommand(
name: 'akeneo:batch:products',
description: 'Import batch product ids from Akeneo PIM.',
)]
final class BatchImportProductsCommand extends AbstractBatchCommand
{
protected static $defaultDescription = 'Import batch product ids from Akeneo PIM.';

/** @var string */
protected static $defaultName = 'akeneo:batch:products';

public function __construct(
private ClientFactoryInterface $clientFactory,
private LoggerInterface $akeneoLogger,
private ClientFactoryInterface $clientFactory,
private BatchProductsTask $batchProductGroupsTask,
) {
parent::__construct(self::$defaultName);
parent::__construct();
}

/**
Expand All @@ -38,13 +39,13 @@ protected function execute(
$ids = explode(',', $input->getArgument('ids'));

$this->akeneoLogger->notice('Processing batch', ['from_id' => $ids[0], 'to_id' => $ids[\count($ids) - 1]]);
$this->akeneoLogger->debug(self::$defaultName, ['batched_ids' => $ids]);
$this->akeneoLogger->debug($this->getName() ?? '', ['batched_ids' => $ids]);

$productModelPayload = new ProductPayload($this->clientFactory->createFromApiCredentials());
$productModelPayload->setIds($ids);

$this->batchProductGroupsTask->__invoke($productModelPayload);

return 0;
return Command::SUCCESS;
}
}
Loading

0 comments on commit eef385c

Please sign in to comment.