Skip to content

Commit b98eebe

Browse files
committed
conf
1 parent e016533 commit b98eebe

File tree

4 files changed

+30
-41
lines changed

4 files changed

+30
-41
lines changed

src/ai-bundle/config/console.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
->set('console.command.ai.setup_store', SetupStoreCommand::class)
2020
->args([
2121
service('ai.store_locator'),
22-
[], // Receiver names
22+
[], // Store names
2323
])
2424
->tag('console.command')
2525
->set('console.command.ai.drop_store', DropStoreCommand::class)
2626
->args([
2727
service('ai.store_locator'),
28-
[], // Receiver names
28+
[], // Store names
2929
])
3030
->tag('console.command')
3131
;

src/store/src/Command/DropStoreCommand.php

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,23 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6767
{
6868
$io = new SymfonyStyle($input, $output);
6969

70-
$storeNames = $this->storeNames;
71-
// do we want to set up only one store?
72-
if ($store = $input->getArgument('store')) {
73-
if (!$this->storeLocator->has($store)) {
74-
throw new RuntimeException(\sprintf('The "%s" store does not exist.', $store));
75-
}
76-
$storeNames = [$store];
70+
$storeName = $input->getArgument('store');
71+
if (!$this->storeLocator->has($storeName)) {
72+
throw new RuntimeException(\sprintf('The "%s" store does not exist.', $storeName));
7773
}
7874

79-
foreach ($storeNames as $storeName) {
80-
$store = $this->storeLocator->get($storeName);
81-
if (!$store instanceof ManagedStoreInterface) {
82-
$io->note(\sprintf('The "%s" store does not support drop.', $storeName));
83-
continue;
84-
}
75+
$store = $this->storeLocator->get($storeName);
76+
if (!$store instanceof ManagedStoreInterface) {
77+
$io->note(\sprintf('The "%s" store does not support be dropped.', $storeName));
8578

86-
try {
87-
$store->drop();
88-
$io->success(\sprintf('The "%s" store was dropped successfully.', $storeName));
89-
} catch (\Exception $e) {
90-
throw new RuntimeException(\sprintf('An error occurred while dropping the "%s" store: ', $storeName).$e->getMessage(), 0, $e);
91-
}
79+
return Command::FAILURE;
80+
}
81+
82+
try {
83+
$store->setup();
84+
$io->success(\sprintf('The "%s" store was dropped successfully.', $storeName));
85+
} catch (\Exception $e) {
86+
throw new RuntimeException(\sprintf('An error occurred while dropping the "%s" store: ', $storeName).$e->getMessage(), 0, $e);
9287
}
9388

9489
return Command::SUCCESS;

src/store/src/Command/SetupStoreCommand.php

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,29 +67,23 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6767
{
6868
$io = new SymfonyStyle($input, $output);
6969

70-
$storeNames = $this->storeNames;
71-
// do we want to set up only one store?
72-
if ($store = $input->getArgument('store')) {
73-
if (!$this->storeLocator->has($store)) {
74-
throw new RuntimeException(\sprintf('The "%s" store does not exist.', $store));
75-
}
76-
$storeNames = [$store];
70+
$storeName = $input->getArgument('store');
71+
if (!$this->storeLocator->has($storeName)) {
72+
throw new RuntimeException(\sprintf('The "%s" store does not exist.', $storeName));
7773
}
7874

79-
foreach ($storeNames as $storeName) {
80-
$store = $this->storeLocator->get($storeName);
81-
if (!$store instanceof ManagedStoreInterface) {
82-
$io->note(\sprintf('The "%s" store does not support setup.', $storeName));
75+
$store = $this->storeLocator->get($storeName);
76+
if (!$store instanceof ManagedStoreInterface) {
77+
$io->note(\sprintf('The "%s" store does not support setup.', $storeName));
8378

84-
continue;
85-
}
79+
return Command::FAILURE;
80+
}
8681

87-
try {
88-
$store->setup();
89-
$io->success(\sprintf('The "%s" store was set up successfully.', $storeName));
90-
} catch (\Exception $e) {
91-
throw new RuntimeException(\sprintf('An error occurred while setting up the "%s" store: ', $storeName).$e->getMessage(), 0, $e);
92-
}
82+
try {
83+
$store->setup();
84+
$io->success(\sprintf('The "%s" store was set up successfully.', $storeName));
85+
} catch (\Exception $e) {
86+
throw new RuntimeException(\sprintf('An error occurred while setting up the "%s" store: ', $storeName).$e->getMessage(), 0, $e);
9387
}
9488

9589
return Command::SUCCESS;

src/store/tests/Command/DropStoreCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testCommandCannotSetupInvalidStore()
6969
'store' => 'foo',
7070
]);
7171

72-
$this->assertStringContainsString('The "foo" store does not support drop.', $tester->getDisplay());
72+
$this->assertStringContainsString('The "foo" store does not support be dropped.', $tester->getDisplay());
7373
}
7474

7575
public function testCommandCannotSetupStoreWithException()

0 commit comments

Comments
 (0)