Skip to content

Commit 96f69c9

Browse files
committed
style: fix code style
1 parent 6bd3091 commit 96f69c9

11 files changed

+318
-348
lines changed

src/Action/LoadPluginAction.php

Lines changed: 50 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,60 @@
66

77
use Composer\Semver\Semver;
88
use NuonicPluginInstaller\Service\IndexFileServiceInterface;
9+
use Shopware\Core\Framework\Context;
910
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
1011
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
1112
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
1213
use Shopware\Core\Framework\Uuid\Uuid;
1314

14-
class LoadPluginAction
15+
readonly class LoadPluginAction
1516
{
16-
public function __construct(
17-
private readonly EntityRepository $availableOpensourcePluginRepository,
18-
private readonly IndexFileServiceInterface $indexFileService
19-
) {
20-
// This is a constructor
21-
}
22-
23-
public function execute(string $packageName)
24-
{
25-
$packageInformation = $this->indexFileService->getPackageInformation($packageName);
26-
27-
if ($packageInformation === null) {
28-
return;
29-
}
30-
31-
$repositoryUrl = $packageInformation->repositoryUrl;
32-
$ref = $packageInformation->ref;
33-
34-
$packagistData = $this->getPackagistData($ref);
35-
36-
$version = $this->findSuitableVersion($packagistData);
37-
38-
39-
$plugin = $this->availableOpensourcePluginRepository->search(
40-
(new Criteria())->addFilter(new EqualsFilter('packageName', $packageName)),
41-
\Shopware\Core\Framework\Context::createDefaultContext()
42-
)->first();
43-
44-
$id = $plugin?->getId() ?? Uuid::randomHex();
45-
}
46-
47-
private function findSuitableVersion(array $packagistData): string
48-
{
49-
$test = 1;
50-
return "";
51-
}
52-
53-
private function getPackagistData(string $ref)
54-
{
55-
$packagistData = file_get_contents($ref);
56-
$packagistData = json_decode($packagistData, true);
57-
return $packagistData;
58-
}
59-
60-
private function checkVersionConstraint(string $constraint, string $version): bool
61-
{
62-
return Semver::satisfies($version, $constraint);
63-
}
17+
public function __construct(
18+
private EntityRepository $availableOpensourcePluginRepository,
19+
private IndexFileServiceInterface $indexFileService,
20+
) {
21+
}
22+
23+
public function execute(string $packageName): void
24+
{
25+
$packageInformation = $this->indexFileService->getPackageInformation($packageName);
26+
27+
if (null === $packageInformation) {
28+
return;
29+
}
30+
31+
$repositoryUrl = $packageInformation->repositoryUrl;
32+
$ref = $packageInformation->ref;
33+
34+
$packagistData = $this->getPackagistData($ref);
35+
36+
$version = $this->findSuitableVersion($packagistData);
37+
38+
$plugin = $this->availableOpensourcePluginRepository->search(
39+
(new Criteria())->addFilter(new EqualsFilter('packageName', $packageName)),
40+
Context::createDefaultContext()
41+
)->first();
42+
43+
$id = $plugin?->getId() ?? Uuid::randomHex();
44+
}
45+
46+
private function findSuitableVersion(array $packagistData): string
47+
{
48+
$test = 1;
49+
50+
return '';
51+
}
52+
53+
private function getPackagistData(string $ref)
54+
{
55+
$packagistData = file_get_contents($ref);
56+
$packagistData = json_decode($packagistData, true);
57+
58+
return $packagistData;
59+
}
60+
61+
private function checkVersionConstraint(string $constraint, string $version): bool
62+
{
63+
return Semver::satisfies($version, $constraint);
64+
}
6465
}

src/Command/TestPluginLoaderAction.php

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,34 @@
55
namespace NuonicPluginInstaller\Command;
66

77
use NuonicPluginInstaller\Action\LoadPluginAction;
8+
use Symfony\Component\Console\Attribute\AsCommand;
89
use Symfony\Component\Console\Command\Command;
910
use Symfony\Component\Console\Input\InputInterface;
10-
use Symfony\Component\Console\Output\OutputInterface;
11-
use Symfony\Component\Console\Attribute\AsCommand;
1211
use Symfony\Component\Console\Input\InputOption;
12+
use Symfony\Component\Console\Output\OutputInterface;
1313

1414
// Command name
1515
#[AsCommand(name: 'nuonic:plugin-installer:plugin:load')]
1616
class TestPluginLoaderAction extends Command
1717
{
18-
public function __construct(
19-
private LoadPluginAction $loadPluginAction,
20-
) {
21-
parent::__construct();
22-
}
23-
// Provides a description, printed out in bin/console
24-
protected function configure(): void
25-
{
26-
$this->setDescription('Tests LoadPluginAction');
27-
$this->addOption('packageName', 'p', InputOption::VALUE_REQUIRED, 'Package name to load');
28-
}
18+
public function __construct(
19+
private LoadPluginAction $loadPluginAction,
20+
) {
21+
parent::__construct();
22+
}
23+
24+
// Provides a description, printed out in bin/console
25+
protected function configure(): void
26+
{
27+
$this->setDescription('Tests LoadPluginAction');
28+
$this->addOption('packageName', 'p', InputOption::VALUE_REQUIRED, 'Package name to load');
29+
}
30+
31+
// Actual code executed in the command
32+
protected function execute(InputInterface $input, OutputInterface $output): int
33+
{
34+
$this->loadPluginAction->execute($input->getOption('packageName'));
2935

30-
// Actual code executed in the command
31-
protected function execute(InputInterface $input, OutputInterface $output): int
32-
{
33-
$this->loadPluginAction->execute($input->getOption('packageName'));
34-
return Command::SUCCESS;
35-
}
36+
return Command::SUCCESS;
37+
}
3638
}

src/Core/Framework/Plugin/AvailableOpensourcePlugin/Aggregate/AvailableOpensourcePluginTranslation/AvailableOpensourcePluginTranslationCollection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
class AvailableOpensourcePluginTranslationCollection extends EntityCollection
1010
{
11-
protected function getExpectedClass(): string
12-
{
13-
return AvailableOpensourcePluginTranslationEntity::class;
14-
}
11+
protected function getExpectedClass(): string
12+
{
13+
return AvailableOpensourcePluginTranslationEntity::class;
14+
}
1515
}

src/Core/Framework/Plugin/AvailableOpensourcePlugin/Aggregate/AvailableOpensourcePluginTranslation/AvailableOpensourcePluginTranslationDefinition.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,28 @@
1212

1313
class AvailableOpensourcePluginTranslationDefinition extends EntityTranslationDefinition
1414
{
15-
public const ENTITY_NAME = 'nuonic_available_opensource_plugin_translation';
16-
17-
public function getEntityName(): string
18-
{
19-
return self::ENTITY_NAME;
20-
}
21-
22-
public function getParentDefinitionClass(): string
23-
{
24-
return AvailableOpensourcePluginDefinition::class;
25-
}
26-
27-
public function getEntityClass(): string
28-
{
29-
return AvailableOpensourcePluginTranslationEntity::class;
30-
}
31-
32-
protected function defineFields(): FieldCollection
33-
{
34-
return new FieldCollection([
35-
(new StringField('name', 'name'))->addFlags(new Required()),
36-
(new StringField('description', 'description'))->addFlags(new Required()),
37-
]);
38-
}
15+
public const ENTITY_NAME = 'nuonic_available_opensource_plugin_translation';
16+
17+
public function getEntityName(): string
18+
{
19+
return self::ENTITY_NAME;
20+
}
21+
22+
public function getParentDefinitionClass(): string
23+
{
24+
return AvailableOpensourcePluginDefinition::class;
25+
}
26+
27+
public function getEntityClass(): string
28+
{
29+
return AvailableOpensourcePluginTranslationEntity::class;
30+
}
31+
32+
protected function defineFields(): FieldCollection
33+
{
34+
return new FieldCollection([
35+
(new StringField('name', 'name'))->addFlags(new Required()),
36+
(new StringField('description', 'description'))->addFlags(new Required()),
37+
]);
38+
}
3939
}

src/Core/Framework/Plugin/AvailableOpensourcePlugin/Aggregate/AvailableOpensourcePluginTranslation/AvailableOpensourcePluginTranslationEntity.php

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,51 @@
99

1010
class AvailableOpensourcePluginTranslationEntity extends TranslationEntity
1111
{
12-
protected string $nuonicAvailableOpensourcePluginId;
12+
protected string $nuonicAvailableOpensourcePluginId;
1313

14-
protected string $name;
14+
protected string $name;
1515

16-
protected string $description;
16+
protected string $description;
1717

18-
protected AvailableOpensourcePluginEntity $nuonicAvailableOpensourcePlugin;
18+
protected AvailableOpensourcePluginEntity $nuonicAvailableOpensourcePlugin;
1919

20-
public function getName(): string
21-
{
22-
return $this->name;
23-
}
20+
public function getName(): string
21+
{
22+
return $this->name;
23+
}
2424

25-
public function setName(string $name): void
26-
{
27-
$this->name = $name;
28-
}
25+
public function setName(string $name): void
26+
{
27+
$this->name = $name;
28+
}
2929

30-
public function getDescription(): string
31-
{
32-
return $this->description;
33-
}
30+
public function getDescription(): string
31+
{
32+
return $this->description;
33+
}
3434

35-
public function setDescription(string $description): void
36-
{
37-
$this->description = $description;
38-
}
35+
public function setDescription(string $description): void
36+
{
37+
$this->description = $description;
38+
}
3939

40-
public function getNuonicAvailableOpensourcePluginId(): string
41-
{
42-
return $this->nuonicAvailableOpensourcePluginId;
43-
}
40+
public function getNuonicAvailableOpensourcePluginId(): string
41+
{
42+
return $this->nuonicAvailableOpensourcePluginId;
43+
}
4444

45-
public function setNuonicAvailableOpensourcePluginId(string $nuonicAvailableOpensourcePluginId): void
46-
{
47-
$this->nuonicAvailableOpensourcePluginId = $nuonicAvailableOpensourcePluginId;
48-
}
45+
public function setNuonicAvailableOpensourcePluginId(string $nuonicAvailableOpensourcePluginId): void
46+
{
47+
$this->nuonicAvailableOpensourcePluginId = $nuonicAvailableOpensourcePluginId;
48+
}
4949

50-
public function getNuonicAvailableOpensourcePlugin(): AvailableOpensourcePluginEntity
51-
{
52-
return $this->nuonicAvailableOpensourcePlugin;
53-
}
50+
public function getNuonicAvailableOpensourcePlugin(): AvailableOpensourcePluginEntity
51+
{
52+
return $this->nuonicAvailableOpensourcePlugin;
53+
}
5454

55-
public function setNuonicAvailableOpensourcePlugin(AvailableOpensourcePluginEntity $nuonicAvailableOpensourcePlugin): void
56-
{
57-
$this->nuonicAvailableOpensourcePlugin = $nuonicAvailableOpensourcePlugin;
58-
}
55+
public function setNuonicAvailableOpensourcePlugin(AvailableOpensourcePluginEntity $nuonicAvailableOpensourcePlugin): void
56+
{
57+
$this->nuonicAvailableOpensourcePlugin = $nuonicAvailableOpensourcePlugin;
58+
}
5959
}

src/Core/Framework/Plugin/AvailableOpensourcePlugin/AvailableOpensourcePluginCollection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
class AvailableOpensourcePluginCollection extends EntityCollection
1010
{
11-
protected function getExpectedClass(): string
12-
{
13-
return AvailableOpensourcePluginEntity::class;
14-
}
11+
protected function getExpectedClass(): string
12+
{
13+
return AvailableOpensourcePluginEntity::class;
14+
}
1515
}

0 commit comments

Comments
 (0)