Skip to content
This repository was archived by the owner on Jun 25, 2025. It is now read-only.

Commit 58c9ebb

Browse files
committed
Moved all index methods to AppRepository
- Using new PHP Client version - Index commands (create, delete, reset) work now with new AppRepository methods
1 parent 8de4162 commit 58c9ebb

File tree

14 files changed

+326
-64
lines changed

14 files changed

+326
-64
lines changed

.php_cs.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"php":"7.1.12-1+ubuntu16.04.1+deb.sury.org+1","version":"2.12.2:v2.12.2#dcc87d5414e9d0bd316fce81a5bedb9ce720b183","rules":{"blank_line_after_namespace":true,"braces":{"allow_single_line_closure":true},"class_definition":{"single_line":true},"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"binary_operator_spaces":true,"blank_line_after_opening_tag":true,"blank_line_before_statement":{"statements":["return"]},"cast_spaces":true,"class_attributes_separation":{"elements":["method"]},"concat_space":{"spacing":"none"},"declare_equal_normalize":true,"function_typehint_space":true,"include":true,"increment_style":true,"lowercase_cast":true,"lowercase_static_reference":true,"magic_constant_casing":true,"native_function_casing":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["curly_brace_block","extra","parenthesis_brace_block","square_brace_block","throw","use"]},"no_leading_import_slash":true,"no_leading_namespace_whitespace":true,"no_mixed_echo_print":{"use":"echo"},"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":true,"no_unneeded_curly_braces":true,"no_unneeded_final_method":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"no_whitespace_in_blank_line":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"php_unit_fqcn_annotation":true,"phpdoc_align":{"tags":["method","param","property","return","throws","type","var"]},"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_empty_return":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_types":true,"phpdoc_var_without_name":true,"protected_to_private":true,"return_type_declaration":true,"semicolon_after_instruction":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_line_comment_style":{"comment_types":["hash"]},"single_quote":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"ternary_operator_spaces":true,"trailing_comma_in_multiline_array":true,"trim_array_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":true},"hashes":{"Tests\/Functional\/ProductBothTransformer.php":867457285,"Tests\/Functional\/ProductReadTransformer.php":2626856266,"Tests\/Functional\/ProductWriteTransformer.php":2104628656,"Tests\/Functional\/DependencyInjection\/CompilerPass\/TransformersCompilerPassTest.php":1561326636,"Tests\/Functional\/DependencyInjection\/ApisearchConfigurationTest.php":1733355149,"Translator\/AggregationTranslator.php":2149846265,"ApisearchBundle.php":3428693615,"Twig\/MethodAccessorExtension.php":2679933104,"Twig\/AggregationTranslationExtension.php":3642617554,"Twig\/UrlBuilderExtension.php":1291295672,"Command\/ImportIndexCommand.php":2053986604,"Command\/CreateIndexCommand.php":426700519,"Command\/ApisearchFormattedCommand.php":2568151029,"Command\/ResetIndexCommand.php":2080515326,"Command\/DeleteIndexCommand.php":3216247700,"Command\/ApisearchCommand.php":3637014326,"Command\/WithAppRepositoryBucketCommand.php":1019748087,"Command\/DeleteTokensCommand.php":3099131500,"Command\/AddTokenCommand.php":3719263640,"Command\/PrintTokensCommand.php":2519214187,"Command\/ExportIndexCommand.php":1299768170,"Command\/WithRepositoryBucketCommand.php":3726182334,"Command\/DeleteTokenCommand.php":1679260907,"DependencyInjection\/CompilerPass\/WriteTransformerCompilerPass.php":42015903,"DependencyInjection\/CompilerPass\/ExporterCompilerPass.php":4087972938,"DependencyInjection\/CompilerPass\/RepositoryCompilerPass.php":1110913584,"DependencyInjection\/CompilerPass\/ReadTransformerCompilerPass.php":1677896883,"DependencyInjection\/ApisearchConfiguration.php":3734743539,"DependencyInjection\/ApisearchExtension.php":2334454061}}
1+
{"php":"7.1.12-1+ubuntu16.04.1+deb.sury.org+1","version":"2.13.0:v2.13.0#7136aa4e0c5f912e8af82383775460d906168a10","rules":{"blank_line_after_namespace":true,"braces":{"allow_single_line_closure":true},"class_definition":{"single_line":true},"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"binary_operator_spaces":true,"blank_line_after_opening_tag":true,"blank_line_before_statement":{"statements":["return"]},"cast_spaces":true,"class_attributes_separation":{"elements":["method"]},"concat_space":{"spacing":"none"},"declare_equal_normalize":true,"function_typehint_space":true,"include":true,"increment_style":true,"lowercase_cast":true,"lowercase_static_reference":true,"magic_constant_casing":true,"magic_method_casing":true,"native_function_casing":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["curly_brace_block","extra","parenthesis_brace_block","square_brace_block","throw","use"]},"no_leading_import_slash":true,"no_leading_namespace_whitespace":true,"no_mixed_echo_print":{"use":"echo"},"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":true,"no_unneeded_curly_braces":true,"no_unneeded_final_method":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"no_whitespace_in_blank_line":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"php_unit_fqcn_annotation":true,"phpdoc_align":{"tags":["method","param","property","return","throws","type","var"]},"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_empty_return":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_types":true,"phpdoc_var_without_name":true,"protected_to_private":true,"return_type_declaration":true,"semicolon_after_instruction":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_line_comment_style":{"comment_types":["hash"]},"single_quote":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"ternary_operator_spaces":true,"trailing_comma_in_multiline_array":true,"trim_array_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":true},"hashes":{"Tests\/Functional\/ProductBothTransformer.php":3061253314,"Tests\/Functional\/ProductReadTransformer.php":1666987200,"Tests\/Functional\/ProductWriteTransformer.php":4090808924,"Tests\/Functional\/DependencyInjection\/CompilerPass\/InMemoryRepositoryCompilerPassTest.php":1181469493,"Tests\/Functional\/DependencyInjection\/CompilerPass\/TransformersCompilerPassTest.php":2186592420,"Tests\/Functional\/DependencyInjection\/CompilerPass\/HttpRepositoryCompilerPassTest.php":4000035678,"Tests\/Functional\/DependencyInjection\/ApisearchConfigurationTest.php":1623406226,"Translator\/AggregationTranslator.php":3471296845,"ApisearchBundle.php":3640212495,"Twig\/MethodAccessorExtension.php":2939807874,"Twig\/AggregationTranslationExtension.php":2415810000,"Twig\/UrlBuilderExtension.php":2201893333,"Command\/ImportIndexCommand.php":1581740785,"Command\/CreateIndexCommand.php":3936840864,"Command\/ApisearchFormattedCommand.php":1606549717,"Command\/ResetIndexCommand.php":2081910409,"Command\/DeleteIndexCommand.php":2044175677,"Command\/ApisearchCommand.php":2188021223,"Command\/WithAppRepositoryBucketCommand.php":2106806880,"Command\/DeleteTokensCommand.php":1800041030,"Command\/AddTokenCommand.php":1932082409,"Command\/PrintTokensCommand.php":2376828112,"Command\/ExportIndexCommand.php":1321012391,"Command\/WithRepositoryBucketCommand.php":3882313592,"Command\/DeleteTokenCommand.php":3019199442,"DependencyInjection\/CompilerPass\/WriteTransformerCompilerPass.php":2530587380,"DependencyInjection\/CompilerPass\/ExporterCompilerPass.php":857546720,"DependencyInjection\/CompilerPass\/RepositoryCompilerPass.php":146592760,"DependencyInjection\/CompilerPass\/ReadTransformerCompilerPass.php":3948110591,"DependencyInjection\/ApisearchConfiguration.php":3473367980,"DependencyInjection\/ApisearchExtension.php":1114385601}}

Command/AddTokenCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
namespace Apisearch\Command;
1717

18-
use Apisearch\Token\Token;
19-
use Apisearch\Token\TokenUUID;
18+
use Apisearch\Model\Token;
19+
use Apisearch\Model\TokenUUID;
2020
use Ramsey\Uuid\Uuid;
2121
use Symfony\Component\Console\Input\InputArgument;
2222
use Symfony\Component\Console\Input\InputInterface;
@@ -37,9 +37,9 @@ protected function configure()
3737
->setName('apisearch:add-token')
3838
->setDescription('Add a token')
3939
->addArgument(
40-
'repository',
40+
'app-name',
4141
InputArgument::REQUIRED,
42-
'Repository name'
42+
'App name'
4343
)
4444
->addArgument(
4545
'uuid',
@@ -140,7 +140,7 @@ protected function runCommand(InputInterface $input, OutputInterface $output)
140140
$endpoints = $this->getEndpoints($input, $output);
141141

142142
$this
143-
->repositoryBucket->findRepository($input->getArgument('repository'))
143+
->repositoryBucket->findRepository($input->getArgument('app-name'))
144144
->addToken(
145145
new Token(
146146
TokenUUID::createById($input->getArgument('uuid')),

Command/CreateIndexCommand.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
use Apisearch\Config\ImmutableConfig;
1919
use Apisearch\Exception\ResourceNotAvailableException;
20+
use Apisearch\Model\IndexUUID;
2021
use Symfony\Component\Console\Input\InputArgument;
2122
use Symfony\Component\Console\Input\InputInterface;
2223
use Symfony\Component\Console\Input\InputOption;
@@ -25,7 +26,7 @@
2526
/**
2627
* Class CreateIndexCommand.
2728
*/
28-
class CreateIndexCommand extends WithRepositoryBucketCommand
29+
class CreateIndexCommand extends WithAppRepositoryBucketCommand
2930
{
3031
/**
3132
* Configures the current command.
@@ -36,9 +37,9 @@ protected function configure()
3637
->setName('apisearch:create-index')
3738
->setDescription('Create an index')
3839
->addArgument(
39-
'repository',
40+
'app-name',
4041
InputArgument::REQUIRED,
41-
'Repository'
42+
'App name'
4243
)
4344
->addArgument(
4445
'index',
@@ -86,14 +87,15 @@ protected function getHeader(): string
8687
*/
8788
protected function runCommand(InputInterface $input, OutputInterface $output)
8889
{
89-
$repository = $input->getArgument('repository');
90+
$appName = $input->getArgument('app-name');
9091
$index = $input->getArgument('index');
9192

9293
try {
9394
$this
9495
->repositoryBucket
95-
->findRepository($repository, $index)
96+
->findRepository($appName)
9697
->createIndex(
98+
new IndexUUID($index),
9799
ImmutableConfig::createFromArray([
98100
'language' => $input->getOption('language'),
99101
'store_searchable_metadata' => !$input->getOption('no-store-searchable-metadata'),

Command/DeleteIndexCommand.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
namespace Apisearch\Command;
1717

1818
use Apisearch\Exception\ResourceNotAvailableException;
19+
use Apisearch\Model\IndexUUID;
1920
use Symfony\Component\Console\Input\InputArgument;
2021
use Symfony\Component\Console\Input\InputInterface;
2122
use Symfony\Component\Console\Output\OutputInterface;
2223

2324
/**
2425
* Class DeleteIndexCommand.
2526
*/
26-
class DeleteIndexCommand extends WithRepositoryBucketCommand
27+
class DeleteIndexCommand extends WithAppRepositoryBucketCommand
2728
{
2829
/**
2930
* Configures the current command.
@@ -34,9 +35,9 @@ protected function configure()
3435
->setName('apisearch:delete-index')
3536
->setDescription('Delete an index')
3637
->addArgument(
37-
'repository',
38+
'app-name',
3839
InputArgument::REQUIRED,
39-
'Repository'
40+
'App name'
4041
)
4142
->addArgument(
4243
'index',
@@ -65,14 +66,14 @@ protected function getHeader(): string
6566
*/
6667
protected function runCommand(InputInterface $input, OutputInterface $output)
6768
{
68-
$repository = $input->getArgument('repository');
69+
$appName = $input->getArgument('app-name');
6970
$index = $input->getArgument('index');
7071

7172
try {
7273
$this
7374
->repositoryBucket
74-
->findRepository($repository, $index)
75-
->deleteIndex();
75+
->findRepository($appName)
76+
->deleteIndex(new IndexUUID($index));
7677
} catch (ResourceNotAvailableException $exception) {
7778
$this->printInfoMessage(
7879
$output,

Command/DeleteTokenCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace Apisearch\Command;
1717

18-
use Apisearch\Token\TokenUUID;
18+
use Apisearch\Model\TokenUUID;
1919
use Symfony\Component\Console\Input\InputArgument;
2020
use Symfony\Component\Console\Input\InputInterface;
2121
use Symfony\Component\Console\Output\OutputInterface;
@@ -34,9 +34,9 @@ protected function configure()
3434
->setName('apisearch:delete-token')
3535
->setDescription('Delete a token')
3636
->addArgument(
37-
'repository',
37+
'app-name',
3838
InputArgument::REQUIRED,
39-
'Repository Name'
39+
'App Name'
4040
)
4141
->addArgument(
4242
'uuid',
@@ -86,7 +86,7 @@ protected function runCommand(InputInterface $input, OutputInterface $output)
8686
$this->getRepositoryAndIndices($input, $output);
8787

8888
$this
89-
->repositoryBucket->findRepository($input->getArgument('repository'))
89+
->repositoryBucket->findRepository($input->getArgument('app-name'))
9090
->deleteToken(
9191
TokenUUID::createById($input->getArgument('uuid'))
9292
);

Command/DeleteTokensCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ protected function configure()
3333
->setName('apisearch:delete-all-token')
3434
->setDescription('Delete all tokens')
3535
->addArgument(
36-
'repository',
36+
'app-name',
3737
InputArgument::REQUIRED,
38-
'Repository name'
38+
'App name'
3939
);
4040
}
4141

@@ -49,9 +49,9 @@ protected function configure()
4949
*/
5050
protected function runCommand(InputInterface $input, OutputInterface $output)
5151
{
52-
$repository = $input->getArgument('repository');
52+
$appName = $input->getArgument('app-name');
5353
$this
54-
->repositoryBucket->findRepository($repository)
54+
->repositoryBucket->findRepository($appName)
5555
->deleteTokens();
5656
}
5757

Command/ExportIndexCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ protected function configure()
3636
->setName('apisearch:export-index')
3737
->setDescription('Export your index')
3838
->addArgument(
39-
'repository',
39+
'app-name',
4040
InputArgument::REQUIRED,
41-
'Repository name'
41+
'App name'
4242
)
4343
->addArgument(
4444
'index',
@@ -72,7 +72,7 @@ protected function getHeader(): string
7272
*/
7373
protected function runCommand(InputInterface $input, OutputInterface $output)
7474
{
75-
$repositoryName = $input->getArgument('repository');
75+
$appName = $input->getArgument('app-name');
7676
$indexName = $input->getArgument('index');
7777
$file = $input->getArgument('file');
7878
$resource = fopen($file, 'w');
@@ -82,7 +82,7 @@ protected function runCommand(InputInterface $input, OutputInterface $output)
8282
$items = $this
8383
->repositoryBucket
8484
->findRepository(
85-
$repositoryName,
85+
$appName,
8686
$indexName
8787
)
8888
->query(Query::create('', $i, 100))

Command/ImportIndexCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ protected function configure()
3434
->setName('apisearch:import-index')
3535
->setDescription('Import your index')
3636
->addArgument(
37-
'repository',
37+
'app-name',
3838
InputArgument::REQUIRED,
39-
'Repository name'
39+
'App name'
4040
)
4141
->addArgument(
4242
'index',
@@ -70,13 +70,13 @@ protected function getHeader(): string
7070
*/
7171
protected function runCommand(InputInterface $input, OutputInterface $output)
7272
{
73-
$repositoryName = $input->getArgument('repository');
73+
$appName = $input->getArgument('app-name');
7474
$indexName = $input->getArgument('index');
7575
$file = $input->getArgument('file');
7676
$repository = $this
7777
->repositoryBucket
7878
->findRepository(
79-
$repositoryName,
79+
$appName,
8080
$indexName
8181
);
8282

Command/PrintTokensCommand.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace Apisearch\Command;
1717

18-
use Apisearch\Token\Token;
18+
use Apisearch\Model\Token;
1919
use Symfony\Component\Console\Helper\Table;
2020
use Symfony\Component\Console\Input\InputArgument;
2121
use Symfony\Component\Console\Input\InputInterface;
@@ -35,9 +35,9 @@ protected function configure()
3535
->setName('apisearch:print-tokens')
3636
->setDescription('Print all tokens of an app-id')
3737
->addArgument(
38-
'repository',
38+
'app-name',
3939
InputArgument::REQUIRED,
40-
'Repository name'
40+
'App name'
4141
);
4242
}
4343

@@ -51,14 +51,14 @@ protected function configure()
5151
*/
5252
protected function runCommand(InputInterface $input, OutputInterface $output)
5353
{
54-
$repository = $input->getArgument('repository');
54+
$appName = $input->getArgument('app-name');
5555
$tokens = $this
56-
->repositoryBucket->findRepository($repository)
56+
->repositoryBucket->findRepository($appName)
5757
->getTokens();
5858

5959
$indexArray = $this
6060
->repositoryBucket
61-
->getConfiguration()[$repository]['indexes'] ?? [];
61+
->getConfiguration()[$appName]['indexes'] ?? [];
6262

6363
/**
6464
* @var Token

0 commit comments

Comments
 (0)