-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
…to portal engine
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
doctrine: | ||
orm: | ||
entity_managers: | ||
pimcore_generic_data_index: | ||
connection: default | ||
mappings: | ||
PimcoreGenericDataIndexBundle: | ||
type: attribute | ||
is_bundle: true | ||
dir: "src/Entity" | ||
prefix: Pimcore\Bundle\GenericDataIndexBundle\Entity | ||
alias: PimcoreGenericDataIndex |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
imports: | ||
- { resource: messenger.yaml } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
framework: | ||
messenger: | ||
enabled: true | ||
transports: | ||
pimcore_index_queues: 'doctrine://default?queue_name=pimcore_index_queues' | ||
routing: | ||
Pimcore\Bundle\GenericDataIndexBundle\Message\IndexUpdateQueueMessage: pimcore_index_queues | ||
buses: | ||
messenger.bus.pimcore-generic-data-index: | ||
middleware: | ||
- 'Pimcore\Bundle\GenericDataIndexBundle\Service\Messenger\Middleware\CollectGarbageMiddleware' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pimcore_generic_data_index_homepage: | ||
path: /pimcore_generic_data_index | ||
defaults: { _controller: Pimcore\Bundle\GenericDataIndexBundle\Controller\DefaultController:indexAction } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,27 @@ | ||
imports: | ||
- { resource: 'services/search/index.yaml' } | ||
- { resource: 'services/search/data-object/*' } | ||
- { resource: 'services/*' } | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
public: false | ||
|
||
# controllers are imported separately to make sure they're public | ||
# and have a tag that allows actions to type-hint services | ||
Pimcore\Bundle\GenericDataIndexBundle\Controller\: | ||
resource: '../src/Controller' | ||
public: true | ||
tags: ['controller.service_arguments'] | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\MessageHandler\: | ||
resource: '../src/MessageHandler' | ||
tags: [ { name: messenger.message_handler, bus: messenger.bus.pimcore-generic-data-index } ] | ||
|
||
# add more services, or override services that need manual wiring | ||
# Pimcore\_generic-data-index-bundle\ExampleClass: | ||
# arguments: | ||
# - "@service_id" | ||
# - "plain_value" | ||
# - "%parameter%" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
||
# auto-register all commands as services | ||
Pimcore\Bundle\GenericDataIndexBundle\Command\: | ||
resource: '../../src/Command/*' | ||
tags: ['console.command'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\Service\DataObject\SelectOptionsService: ~ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\Service\Messenger\Middleware\CollectGarbageMiddleware: ~ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\DefaultAdapter: | ||
shared: false | ||
tags: | ||
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "wysiwyg" } | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\TextAdapter: | ||
shared: false | ||
tags: | ||
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "input" } | ||
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "textarea" } | ||
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "calculatedValue" } | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\NumericAdapter: | ||
shared: false | ||
tags: | ||
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "numeric" } | ||
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "slider" } | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\DateAdapter: | ||
shared: false | ||
tags: | ||
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "date" } | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\DateTimeAdapter: | ||
shared: false | ||
tags: | ||
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "datetime" } | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\LocalizedFieldsAdapter: | ||
shared: false | ||
tags: | ||
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "localizedfields" } | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\QuantityValueAdapter: | ||
shared: false | ||
tags: | ||
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "quantityValue" } | ||
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "inputQuantityValue" } | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\BooleanAdapter: | ||
shared: false | ||
tags: | ||
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "checkbox" } | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\SelectAdapter: | ||
shared: false | ||
tags: | ||
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "select" } | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\MultiSelectAdapter: | ||
shared: false | ||
tags: | ||
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "multiselect" } | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\CountryAdapter: | ||
shared: false | ||
tags: | ||
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "country" } | ||
|
||
#Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\LanguageAdapter: | ||
# shared: false | ||
# tags: | ||
# - { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "language" } | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\CountryMultiSelectAdapter: | ||
shared: false | ||
tags: | ||
- { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "countrymultiselect" } | ||
|
||
#Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\LanguageMultiSelectAdapter: | ||
# shared: false | ||
# tags: | ||
# - { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "languagemultiselect" } | ||
|
||
#Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\ManyToOneRelationAdapter: | ||
# shared: false | ||
# tags: | ||
# - { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "manyToOneRelation" } | ||
|
||
#Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\ManyToManyObjectRelationAdapter: | ||
# shared: false | ||
# tags: | ||
# - { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "manyToManyObjectRelation" } | ||
|
||
#Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\AdvancedManyToManyRelationAdapter: | ||
# shared: false | ||
# tags: | ||
# - { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "advancedManyToManyRelation" } | ||
|
||
#Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\AdvancedManyToManyObjectRelationAdapter: | ||
# shared: false | ||
# tags: | ||
# - { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "advancedManyToManyObjectRelation" } | ||
|
||
#Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionAdapter\ManyToManyRelationAdapter: | ||
# shared: false | ||
# tags: | ||
# - { name: "pimcore.generic_data_index.data-object.search_index_field_definition", type: "manyToManyRelation" } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\LanguageService: ~ | ||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\IndexService\AssetIndexService: ~ | ||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\IndexService\DataObjectIndexService: ~ | ||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\IndexUpdateService: ~ | ||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\IndexQueueService: ~ | ||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\SearchIndexConfigService: ~ | ||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\OpenSearch\OpenSearchService: ~ | ||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\OpenSearch\BulkOperationService: ~ | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\DataObject\FieldDefinitionService: | ||
arguments: | ||
- '@pimcore.generic_data_index.object.search_index_field_definition_locator' | ||
|
||
pimcore.generic_data_index.object.search_index_field_definition_locator: | ||
class: Symfony\Component\DependencyInjection\ServiceLocator | ||
tags: [ 'container.service_locator' ] | ||
arguments: | ||
- [ ] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
||
Pimcore\Bundle\GenericDataIndexBundle\Service\Workflow\WorkflowService: ~ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<?php | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under following license: | ||
* - Pimcore Commercial License (PCL) | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\GenericDataIndexBundle\Command\Update; | ||
|
||
use Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\IndexQueueService; | ||
use Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\IndexUpdateService; | ||
use Pimcore\Console\AbstractCommand; | ||
use Pimcore\Model\DataObject\ClassDefinition; | ||
use Symfony\Component\Console\Command\LockableTrait; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Contracts\Service\Attribute\Required; | ||
|
||
class IndexUpdateCommand extends AbstractCommand | ||
{ | ||
use LockableTrait; | ||
|
||
const OPTION_CLASS_DEFINITION_ID = 'class-definition-id'; | ||
Check notice on line 29 in src/Command/Update/IndexUpdateCommand.php GitHub Actions / Qodana for PHPAccess modifiers shall be defined
|
||
const OPTION_UPDATE_ASSET_INDEX = 'update-asset-index'; | ||
Check notice on line 30 in src/Command/Update/IndexUpdateCommand.php GitHub Actions / Qodana for PHPAccess modifiers shall be defined
|
||
const OPTION_RECREATE_INDEX = 'recreate_index'; | ||
Check notice on line 31 in src/Command/Update/IndexUpdateCommand.php GitHub Actions / Qodana for PHPAccess modifiers shall be defined
|
||
|
||
protected IndexUpdateService $indexUpdateService; | ||
protected IndexQueueService $indexQueueService; | ||
|
||
|
||
protected function configure() | ||
Check warning on line 37 in src/Command/Update/IndexUpdateCommand.php GitHub Actions / Qodana for PHPMissing return type declaration
|
||
{ | ||
$this | ||
->setName('generic-data-index:update:index') | ||
->addOption(self::OPTION_CLASS_DEFINITION_ID, 'cid', InputOption::VALUE_OPTIONAL, 'Update mapping and data for specific data object classDefinition', null) | ||
Check warning on line 41 in src/Command/Update/IndexUpdateCommand.php GitHub Actions / Qodana for PHPLine is longer than allowed by code style
|
||
->addOption(self::OPTION_UPDATE_ASSET_INDEX, 'a', InputOption::VALUE_NONE, 'Update mapping and data for asset index', null) | ||
Check warning on line 42 in src/Command/Update/IndexUpdateCommand.php GitHub Actions / Qodana for PHPLine is longer than allowed by code style
|
||
->addOption(self::OPTION_RECREATE_INDEX, 'r', InputOption::VALUE_NONE, 'Delete OpenSearch index and recreate it', null) | ||
Check warning on line 43 in src/Command/Update/IndexUpdateCommand.php GitHub Actions / Qodana for PHPLine is longer than allowed by code style
|
||
->setDescription('Updates index/mapping for all classDefinitions/asset without deleting them. Adds there elements to index queue.'); | ||
Check warning on line 44 in src/Command/Update/IndexUpdateCommand.php GitHub Actions / Qodana for PHPLine is longer than allowed by code style
|
||
} | ||
|
||
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* | ||
* @throws \Exception | ||
* | ||
* @return int | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
Check warning on line 55 in src/Command/Update/IndexUpdateCommand.php GitHub Actions / Qodana for PHPMissing return type declaration
|
||
{ | ||
if (!$this->lock()) { | ||
throw new \Exception('The command is already running in another process.'); | ||
Check notice on line 58 in src/Command/Update/IndexUpdateCommand.php GitHub Actions / Qodana for PHPFully qualified name usage
|
||
} | ||
|
||
$this->indexUpdateService->setReCreateIndex($input->getOption(self::OPTION_RECREATE_INDEX)); | ||
|
||
$updateAll = true; | ||
|
||
/** @var string|null $classDefinitionId */ | ||
$classDefinitionId = $input->getOption(self::OPTION_CLASS_DEFINITION_ID); | ||
|
||
if ($classDefinitionId) { | ||
$updateAll = false; | ||
|
||
try { | ||
$classDefinition = ClassDefinition::getById($classDefinitionId); | ||
if (!$classDefinition) { | ||
throw new \Exception(sprintf('ClassDefinition with id %s not found', $classDefinitionId)); | ||
Check notice on line 74 in src/Command/Update/IndexUpdateCommand.php GitHub Actions / Qodana for PHPFully qualified name usage
|
||
} | ||
|
||
$this->output->writeln(sprintf('<info>Update index and indices for ClassDefinition with id %s</info>', $classDefinitionId), OutputInterface::VERBOSITY_VERBOSE); | ||
Check warning on line 77 in src/Command/Update/IndexUpdateCommand.php GitHub Actions / Qodana for PHPLine is longer than allowed by code style
|
||
|
||
$this | ||
->indexUpdateService | ||
->updateClassDefinition($classDefinition); | ||
} catch (\Exception $e) { | ||
$this->output->writeln('<error>' . $e->getMessage() . '</error>'); | ||
} | ||
} | ||
|
||
if ($input->getOption(self::OPTION_UPDATE_ASSET_INDEX)) { | ||
$updateAll = false; | ||
|
||
try { | ||
$output->writeln('<info>Update asset index</info>', OutputInterface::VERBOSITY_VERBOSE); | ||
|
||
$this | ||
->indexUpdateService | ||
->updateAssets(); | ||
} catch (\Exception $e) { | ||
$this->output->writeln($e->getMessage()); | ||
} | ||
} | ||
|
||
if ($updateAll) { | ||
$this->output->writeln('<info>Update all mappings and indices for objects/assets</info>', OutputInterface::VERBOSITY_VERBOSE); | ||
Check warning on line 102 in src/Command/Update/IndexUpdateCommand.php GitHub Actions / Qodana for PHPLine is longer than allowed by code style
|
||
|
||
$this | ||
->indexUpdateService | ||
->updateAll(); | ||
} | ||
|
||
$this->indexQueueService->dispatchQueueMessages($output); | ||
|
||
$this->release(); | ||
|
||
$this->output->writeln('<info>Finished</info>', OutputInterface::VERBOSITY_VERBOSE); | ||
|
||
return self::SUCCESS; | ||
} | ||
|
||
#[Required] | ||
public function setIndexUpdateService(IndexUpdateService $indexUpdateService): void | ||
{ | ||
$this->indexUpdateService = $indexUpdateService; | ||
} | ||
|
||
#[Required] | ||
public function setIndexQueueService(IndexQueueService $indexQueueService): void | ||
{ | ||
$this->indexQueueService = $indexQueueService; | ||
} | ||
|
||
} |