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

Commit ff4415c

Browse files
committed
Added delete-all-tokens command
1 parent ee9c7ee commit ff4415c

File tree

4 files changed

+121
-28
lines changed

4 files changed

+121
-28
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.11.1:v2.11.1#ad94441c17b8ef096e517acccdbf3238af8a2da8","rules":{"blank_line_after_namespace":true,"braces":{"allow_single_line_closure":true},"class_definition":{"singleLine":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,"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\/DependencyInjection\/ApisearchConfigurationTest.php":379272062,"Translator\/AggregationTranslator.php":2950948888,"ApisearchBundle.php":452340142,"Twig\/MethodAccessorExtension.php":1937766330,"Twig\/AggregationTranslationExtension.php":1168064907,"Twig\/UrlBuilderExtension.php":1238295593,"Command\/ImportIndexCommand.php":1722481554,"Command\/CreateIndexCommand.php":364387858,"Command\/ApisearchFormattedCommand.php":2617090809,"Command\/ResetIndexCommand.php":4289827141,"Command\/DeleteIndexCommand.php":2797453099,"Command\/ApisearchCommand.php":1883682797,"Command\/WithAppRepositoryBucketCommand.php":3329637861,"Command\/AddTokenCommand.php":436339007,"Command\/PrintTokensCommand.php":3931081773,"Command\/ExportIndexCommand.php":3751299339,"Command\/WithRepositoryBucketCommand.php":835091977,"Command\/DeleteTokenCommand.php":2813018826,"DependencyInjection\/CompilerPass\/TagCompilerPass.php":1857409043,"DependencyInjection\/CompilerPass\/WriteTransformerCompilerPass.php":3787221228,"DependencyInjection\/CompilerPass\/ExporterCompilerPass.php":3859400892,"DependencyInjection\/CompilerPass\/RepositoryCompilerPass.php":3492158054,"DependencyInjection\/CompilerPass\/ReadTransformerCompilerPass.php":407060565,"DependencyInjection\/ApisearchConfiguration.php":2562035961,"DependencyInjection\/ApisearchExtension.php":2861843414}}
1+
{"php":"7.1.12-1+ubuntu16.04.1+deb.sury.org+1","version":"2.11.1:v2.11.1#ad94441c17b8ef096e517acccdbf3238af8a2da8","rules":{"blank_line_after_namespace":true,"braces":{"allow_single_line_closure":true},"class_definition":{"singleLine":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,"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\/DependencyInjection\/ApisearchConfigurationTest.php":379272062,"Translator\/AggregationTranslator.php":2950948888,"ApisearchBundle.php":452340142,"Twig\/MethodAccessorExtension.php":1937766330,"Twig\/AggregationTranslationExtension.php":1168064907,"Twig\/UrlBuilderExtension.php":1238295593,"Command\/ImportIndexCommand.php":1722481554,"Command\/CreateIndexCommand.php":364387858,"Command\/ApisearchFormattedCommand.php":2617090809,"Command\/ResetIndexCommand.php":4289827141,"Command\/DeleteIndexCommand.php":2797453099,"Command\/ApisearchCommand.php":1883682797,"Command\/WithAppRepositoryBucketCommand.php":3329637861,"Command\/AddTokenCommand.php":3164274201,"Command\/PrintTokensCommand.php":2265717038,"Command\/ExportIndexCommand.php":3751299339,"Command\/WithRepositoryBucketCommand.php":835091977,"Command\/DeleteTokenCommand.php":2813018826,"DependencyInjection\/CompilerPass\/TagCompilerPass.php":1857409043,"DependencyInjection\/CompilerPass\/WriteTransformerCompilerPass.php":3787221228,"DependencyInjection\/CompilerPass\/ExporterCompilerPass.php":3859400892,"DependencyInjection\/CompilerPass\/RepositoryCompilerPass.php":3492158054,"DependencyInjection\/CompilerPass\/ReadTransformerCompilerPass.php":407060565,"DependencyInjection\/ApisearchConfiguration.php":2562035961,"DependencyInjection\/ApisearchExtension.php":2861843414,"Command\/DeleteTokensCommand.php":1752254398}}

Command/DeleteTokensCommand.php

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Search PHP Bundle.
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* Feel free to edit as you please, and have fun.
10+
*
11+
* @author Marc Morera <yuhu@mmoreram.com>
12+
* @author PuntMig Technologies
13+
*/
14+
15+
declare(strict_types=1);
16+
17+
namespace Apisearch\Command;
18+
19+
use Symfony\Component\Console\Input\InputArgument;
20+
use Symfony\Component\Console\Input\InputInterface;
21+
use Symfony\Component\Console\Output\OutputInterface;
22+
23+
/**
24+
* Class DeleteTokensCommand.
25+
*/
26+
class DeleteTokensCommand extends WithAppRepositoryBucketCommand
27+
{
28+
/**
29+
* Configures the current command.
30+
*/
31+
protected function configure()
32+
{
33+
$this
34+
->setName('apisearch:delete-all-token')
35+
->setDescription('Delete all tokens')
36+
->addArgument(
37+
'repository',
38+
InputArgument::REQUIRED,
39+
'Repository name'
40+
);
41+
}
42+
43+
/**
44+
* Dispatch domain event.
45+
*
46+
* @param InputInterface $input
47+
* @param OutputInterface $output
48+
*
49+
* @return mixed|null
50+
*/
51+
protected function runCommand(InputInterface $input, OutputInterface $output)
52+
{
53+
$repository = $input->getArgument('repository');
54+
$this
55+
->repositoryBucket->findRepository($repository)
56+
->deleteTokens();
57+
}
58+
59+
/**
60+
* Dispatch domain event.
61+
*
62+
* @return string
63+
*/
64+
protected function getHeader(): string
65+
{
66+
return 'Delete all tokens';
67+
}
68+
69+
/**
70+
* Get success message.
71+
*
72+
* @param InputInterface $input
73+
* @param mixed $result
74+
*
75+
* @return string
76+
*/
77+
protected function getSuccessMessage(
78+
InputInterface $input,
79+
$result
80+
): string {
81+
return sprintf(
82+
'All Tokens deleted properly',
83+
$input->getArgument('uuid')
84+
);
85+
}
86+
}

Command/PrintTokensCommand.php

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,6 @@ protected function configure()
4242
);
4343
}
4444

45-
/**
46-
* Dispatch domain event.
47-
*
48-
* @return string
49-
*/
50-
protected function getHeader(): string
51-
{
52-
return 'Print tokens';
53-
}
54-
55-
/**
56-
* Get success message.
57-
*
58-
* @param InputInterface $input
59-
* @param mixed $result
60-
*
61-
* @return string
62-
*/
63-
protected function getSuccessMessage(
64-
InputInterface $input,
65-
$result
66-
): string {
67-
return '';
68-
}
69-
7045
/**
7146
* Dispatch domain event.
7247
*
@@ -83,8 +58,8 @@ protected function runCommand(InputInterface $input, OutputInterface $output)
8358
->getTokens();
8459

8560
$indexArray = $this
86-
->repositoryBucket
87-
->getConfiguration()[$repository]['indexes'] ?? [];
61+
->repositoryBucket
62+
->getConfiguration()[$repository]['indexes'] ?? [];
8863

8964
/**
9065
* @var Token
@@ -111,4 +86,29 @@ protected function runCommand(InputInterface $input, OutputInterface $output)
11186
}
11287
$table->render();
11388
}
89+
90+
/**
91+
* Dispatch domain event.
92+
*
93+
* @return string
94+
*/
95+
protected function getHeader(): string
96+
{
97+
return 'Print tokens';
98+
}
99+
100+
/**
101+
* Get success message.
102+
*
103+
* @param InputInterface $input
104+
* @param mixed $result
105+
*
106+
* @return string
107+
*/
108+
protected function getSuccessMessage(
109+
InputInterface $input,
110+
$result
111+
): string {
112+
return '';
113+
}
114114
}

Resources/config/commands.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ services:
5858

5959
apisearch.delete_token_command:
6060
class: Apisearch\Command\DeleteTokenCommand
61+
arguments:
62+
- "@apisearch.app_repository_bucket"
63+
tags:
64+
- { name: console.command }
65+
66+
apisearch.delete_all_tokens_command:
67+
class: Apisearch\Command\DeleteTokensCommand
6168
arguments:
6269
- "@apisearch.app_repository_bucket"
6370
tags:

0 commit comments

Comments
 (0)