Skip to content

Commit

Permalink
feat: Index-Name, using ResourceChannel, ResourceLocation and Resourc…
Browse files Browse the repository at this point in the history
…eLangauge
  • Loading branch information
sitepark-veltrup authored May 3, 2024
2 parents e97f23b + 2e2b71a commit be2b5ad
Show file tree
Hide file tree
Showing 178 changed files with 12,469 additions and 41 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
!var/cache/.gitkeep
/var/log/*
!var/log/.gitkeep
/var/test/*
/tools
.phpactor.json
composer.lock
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
[![codecov](https://codecov.io/gh/sitepark/atoolo-resource/graph/badge.svg?token=QwvDRxKEa2)](https://codecov.io/gh/sitepark/atoolo-resource)
[![codecov](https://codecov.io/gh/sitepark/atoolo-search/graph/badge.svg?token=xBMwUzm34b)](https://codecov.io/gh/sitepark/atoolo-search)
![phpstan](https://img.shields.io/badge/PHPStan-level%209-brightgreen)
![php](https://img.shields.io/badge/PHP-8.1-blue)
![php](https://img.shields.io/badge/PHP-8.2-blue)
![php](https://img.shields.io/badge/PHP-8.3-blue)

# Atoolo search

Provides services with which a Solr index can be filled and searched for [resources](https://github.com/sitepark/atoolo-resource) via this index.
Provides services with which a Solr index can be filled and searched for [resources](https://github.com/sitepark/atoolo-resource) via a index.

[Documentation](https://sitepark.github.io/atoolo-docs/develop/components/search/)
20 changes: 20 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env php
<?php
// application.php

require __DIR__.'/../vendor/autoload.php';

use Atoolo\Search\Console\Application;
use Symfony\Component\Config\FileLocator;

$container = new Symfony\Component\DependencyInjection\ContainerBuilder();
$loader = new Symfony\Component\DependencyInjection\Loader\YamlFileLoader(
$container,
new FileLocator(__DIR__ . '/../config'));

$loader->load('commands.yml');
$container->compile();

$application = $container->get(Application::class);

$application->run();
81 changes: 44 additions & 37 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,61 @@
"description": "Indexing und searching",
"license": "MIT",
"type": "library",
"authors": [{
"name": "veltrup",
"email": "veltrup@sitepark.com"
}],
"autoload": {
"psr-4": {
"Atoolo\\Search\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Atoolo\\Search\\Test\\": "test"
"authors": [
{
"name": "veltrup",
"email": "veltrup@sitepark.com"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
],
"require": {
"php": ">=8.1 <8.4.0",
"atoolo/resource": "dev-feature/hierarchy-loader",
"ext-intl": "*",
"atoolo/resource": "dev-main",
"solarium/solarium": "^6.3",
"symfony/config": "^6.3",
"symfony/console": "^6.3",
"symfony/dependency-injection": "^6.3",
"symfony/event-dispatcher": "^6.3",
"symfony/finder": "^6.3",
"symfony/yaml": "^6.3"
"symfony/config": "^6.3 || ^7.0",
"symfony/console": "^6.3 || ^7.0",
"symfony/dependency-injection": "^6.3 || ^7.0",
"symfony/event-dispatcher": "^6.3 || ^7.0",
"symfony/finder": "^6.3 || ^7.0",
"symfony/lock": "^6.3 || ^7.0",
"symfony/property-access": "^6.3 || ^7.0",
"symfony/serializer": "^6.3 || ^7.0",
"symfony/yaml": "^6.3 || ^7.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"infection/infection": "^0.27.6",
"phpcompatibility/php-compatibility": "^9.3",
"phpunit/phpunit": "^10.4",
"roave/security-advisories": "dev-latest",
"squizlabs/php_codesniffer": "^3.7"
"squizlabs/php_codesniffer": "^3.7",
"symfony/filesystem": "^6.3 || ^7.0"
},
"repositories": {},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Atoolo\\Search\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Atoolo\\Search\\Test\\": "test"
}
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"infection/extension-installer": true
},
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"scripts": {

"post-install-cmd": "phive --no-progress install --force-accept-unsigned --trust-gpg-keys C00543248C87FB13,4AA394086372C20A,CF1A108D0E7AE720,51C67305FFC2E5C0",
"analyse": [
"@analyse:phplint",
Expand All @@ -64,18 +82,7 @@
"test": [
"@test:phpunit"
],
"test:phpunit": "./tools/phpunit.phar -c phpunit.xml --coverage-text",
"test:infection": "vendor/bin/infection --threads=8 --no-progress --only-covered -s || exit 0"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"infection/extension-installer": true
},
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
},
"sort-packages": true
"test:infection": "vendor/bin/infection --threads=8 --no-progress --only-covered -s || exit 0",
"test:phpunit": "./tools/phpunit.phar -c phpunit.xml --coverage-text"
}
}
50 changes: 50 additions & 0 deletions config/commands.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
services:
_defaults:
autowire: true
autoconfigure: true
_instanceof:
Symfony\Component\Console\Command\Command:
tags: ['command']

Atoolo\Search\Console\:
resource: '../src/Console'

atoolo.search.indexer.console.progressBar:
class: 'Atoolo\Search\Console\Command\Io\IndexerProgressBar'

Atoolo\Search\Console\Command\Indexer:
arguments:
- '@atoolo.resource.resourceChannelFactory'
- '@atoolo.search.indexer.console.progressBar'
- '@atoolo.search.indexer.indexerCollection'

Atoolo\Search\Console\Command\IndexerInternalResourceUpdate:
arguments:
- '@atoolo.resource.resourceChannelFactory'
- '@atoolo.search.indexer.console.progressBar'
- '@atoolo.search.indexer.internalResourceIndexer'

Atoolo\Search\Console\Command\Search:
arguments:
- '@atoolo.resource.resourceChannelFactory'
- '@atoolo.search.search'

Atoolo\Search\Console\Command\Suggest:
arguments:
- '@atoolo.resource.resourceChannelFactory'
- '@atoolo.search.suggest'

Atoolo\Search\Console\Command\MoreLikeThis:
arguments:
- '@atoolo.resource.resourceChannelFactory'
- '@atoolo.search.moreLikeThis'

Atoolo\Search\Console\Command\DumpIndexDocument:
arguments:
- '@atoolo.resource.resourceChannelFactory'
- '@atoolo.search.indexer.indexDocumentDumper'

Atoolo\Search\Console\Application:
public: true
arguments:
- !tagged command
9 changes: 7 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
bootstrap="vendor/autoload.php"
executionOrder="random"
cacheResultFile="var/cache/.phpunit.result.cache"
cacheDirectory="var/cache/.phpunit.cache">
cacheDirectory="var/cache/.phpunit.cache"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true">

<coverage>
<coverage
disableCodeCoverageIgnore="false">
<report>
<clover outputFile="var/log/clover/clover.xml"/>
<html outputDirectory="var/log/clover"/>
Expand Down
22 changes: 22 additions & 0 deletions src/Console/Application.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace Atoolo\Search\Console;

use Symfony\Component\Console\Application as BaseApplication;
use Symfony\Component\Console\Command\Command;

class Application extends BaseApplication
{
/**
* @param iterable<Command> $commands
*/
public function __construct(iterable $commands = [])
{
parent::__construct();
foreach ($commands as $command) {
$this->add($command);
}
}
}
70 changes: 70 additions & 0 deletions src/Console/Command/DumpIndexDocument.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

declare(strict_types=1);

namespace Atoolo\Search\Console\Command;

use Atoolo\Resource\ResourceChannelFactory;
use Atoolo\Search\Console\Command\Io\TypifiedInput;
use Atoolo\Search\Service\Indexer\IndexDocumentDumper;
use JsonException;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

#[AsCommand(
name: 'search:dump-index-document',
description: 'Dump a index document'
)]
class DumpIndexDocument extends Command
{
public function __construct(
private readonly ResourceChannelFactory $channelFactory,
private readonly IndexDocumentDumper $dumper
) {
parent::__construct();
}

protected function configure(): void
{
$this
->setHelp('Command to dump a index-document')
->addArgument(
'paths',
InputArgument::REQUIRED | InputArgument::IS_ARRAY,
'Resources paths or directories of resources to be indexed.'
)
;
}

/**
* @throws JsonException
*/
protected function execute(
InputInterface $input,
OutputInterface $output
): int {

$typedInput = new TypifiedInput($input);

$paths = $typedInput->getArrayArgument('paths');

$resourceChannel = $this->channelFactory->create();
$io = new SymfonyStyle($input, $output);
$io->title('Channel: ' . $resourceChannel->name);

$dump = $this->dumper->dump($paths);

foreach ($dump as $fields) {
$output->writeln(json_encode(
$fields,
JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT
));
}

return Command::SUCCESS;
}
}
Loading

0 comments on commit be2b5ad

Please sign in to comment.