Skip to content
This repository was archived by the owner on Jun 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ jobs:
- run:
name: Install PHPUnit
command: |
composer require phpunit/phpunit:7.*
composer require phpunit/phpunit:7.5.17 --prefer-dist --prefer-stable --prefer-lowest --no-suggest

- run:
name: Run tests / Symfony 3^3
command: |
php vendor/bin/phpunit

- run:
name: Run tests / Symfony 4^3
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor
var
var
.php_cs.cache
3 changes: 3 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'@Symfony' => true,
'single_line_after_imports' => false,
'no_superfluous_phpdoc_tags' => false,
'single_line_throw' => false
])
->setFinder($finder)
;
1 change: 0 additions & 1 deletion .php_cs.cache

This file was deleted.

2 changes: 2 additions & 0 deletions Command/ApisearchFormattedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

self::finishCommand($stopwatch, $output);

return 0;
}

/**
Expand Down
98 changes: 2 additions & 96 deletions Command/ConfigureIndexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,101 +15,17 @@

namespace Apisearch\Command;

use Apisearch\App\AppRepositoryBucket;
use Apisearch\Config\Config;
use Apisearch\Config\Synonym;
use Apisearch\Config\SynonymReader;
use Apisearch\Exception\ResourceNotAvailableException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Class ConfigureIndexCommand.
*/
class ConfigureIndexCommand extends WithAppRepositoryBucketCommand
class ConfigureIndexCommand extends IndexBasedCommand
{
/**
* @var SynonymReader
*
* Synonym Reader
*/
private $synonymReader;

/**
* WithAppRepositoryBucketCommand constructor.
*
* @param AppRepositoryBucket $repositoryBucket
* @param SynonymReader $synonymReader
*/
public function __construct(
AppRepositoryBucket $repositoryBucket,
SynonymReader $synonymReader
) {
parent::__construct($repositoryBucket);

$this->synonymReader = $synonymReader;
}

/**
* Configures the current command.
*/
protected function configure()
{
$this
->setDescription('Configure an index')
->addArgument(
'app-name',
InputArgument::REQUIRED,
'App name'
)
->addArgument(
'index-name',
InputArgument::REQUIRED,
'Index'
)
->addOption(
'language',
null,
InputOption::VALUE_OPTIONAL,
'Index language',
null
)
->addOption(
'no-store-searchable-metadata',
null,
InputOption::VALUE_NONE,
'Store searchable metadata'
)
->addOption(
'synonym',
null,
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
'Synonym'
)
->addOption(
'synonyms-file',
null,
InputOption::VALUE_OPTIONAL,
'Synonyms file'
)
->addOption(
'shards',
null,
InputOption::VALUE_OPTIONAL,
'Shards for the index',
Config::DEFAULT_SHARDS
)
->addOption(
'replicas',
null,
InputOption::VALUE_OPTIONAL,
'Replicas for the index',
Config::DEFAULT_REPLICAS
);
}

/**
* Dispatch domain event.
*
Expand All @@ -122,17 +38,7 @@ protected function runCommand(InputInterface $input, OutputInterface $output)
{
$appName = $input->getArgument('app-name');
list($_, $indexUUID) = $this->getRepositoryAndIndex($input, $output);
$synonymsFile = $input->getOption('synonyms-file');

$synonyms = !is_null($synonymsFile)
? $this
->synonymReader
->readSynonymsFromFile($input->getOption('synonyms-file'))
: [];

$synonyms += $this
->synonymReader
->readSynonymsFromCommaSeparatedArray($input->getOption('synonym'));
$synonyms = $this->loadSynonyms($input);

try {
$this
Expand Down
98 changes: 2 additions & 96 deletions Command/CreateIndexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,101 +15,17 @@

namespace Apisearch\Command;

use Apisearch\App\AppRepositoryBucket;
use Apisearch\Config\Config;
use Apisearch\Config\Synonym;
use Apisearch\Config\SynonymReader;
use Apisearch\Exception\ResourceNotAvailableException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Class CreateIndexCommand.
*/
class CreateIndexCommand extends WithAppRepositoryBucketCommand
class CreateIndexCommand extends IndexBasedCommand
{
/**
* @var SynonymReader
*
* Synonym Reader
*/
private $synonymReader;

/**
* WithAppRepositoryBucketCommand constructor.
*
* @param AppRepositoryBucket $repositoryBucket
* @param SynonymReader $synonymReader
*/
public function __construct(
AppRepositoryBucket $repositoryBucket,
SynonymReader $synonymReader
) {
parent::__construct($repositoryBucket);

$this->synonymReader = $synonymReader;
}

/**
* Configures the current command.
*/
protected function configure()
{
$this
->setDescription('Create an index')
->addArgument(
'app-name',
InputArgument::REQUIRED,
'App name'
)
->addArgument(
'index-name',
InputArgument::REQUIRED,
'Index name'
)
->addOption(
'language',
null,
InputOption::VALUE_OPTIONAL,
'Index language',
null
)
->addOption(
'no-store-searchable-metadata',
null,
InputOption::VALUE_NONE,
'Store searchable metadata'
)
->addOption(
'synonym',
null,
InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
'Synonym'
)
->addOption(
'synonyms-file',
null,
InputOption::VALUE_OPTIONAL,
'Synonyms file'
)
->addOption(
'shards',
null,
InputOption::VALUE_OPTIONAL,
'Shards for the index',
Config::DEFAULT_SHARDS
)
->addOption(
'replicas',
null,
InputOption::VALUE_OPTIONAL,
'Replicas for the index',
Config::DEFAULT_REPLICAS
);
}

/**
* Dispatch domain event.
*
Expand All @@ -122,17 +38,7 @@ protected function runCommand(InputInterface $input, OutputInterface $output)
{
$appName = $input->getArgument('app-name');
list($_, $indexUUID) = $this->getRepositoryAndIndex($input, $output);
$synonymsFile = $input->getOption('synonyms-file');

$synonyms = !is_null($synonymsFile)
? $this
->synonymReader
->readSynonymsFromFile($input->getOption('synonyms-file'))
: [];

$synonyms += $this
->synonymReader
->readSynonymsFromCommaSeparatedArray($input->getOption('synonym'));
$synonyms = $this->loadSynonyms($input);

try {
$this
Expand Down
Loading