Skip to content

Commit

Permalink
Fix asynchronous enqueueing of assets on save (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-moser authored Feb 9, 2024
1 parent 955d729 commit 4f25922
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\IndexService\ElementTypeAdapter;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Query\QueryBuilder;
use InvalidArgumentException;
use Pimcore\Bundle\GenericDataIndexBundle\Enum\SearchIndex\ElementType;
use Pimcore\Bundle\GenericDataIndexBundle\Enum\SearchIndex\IndexName;
Expand All @@ -30,6 +32,7 @@ final class AssetTypeAdapter extends AbstractElementTypeAdapter
{
public function __construct(
private readonly AssetNormalizer $normalizer,
private readonly Connection $dbConnection,
) {
}

Expand Down Expand Up @@ -73,4 +76,23 @@ public function getUpdateIndexDataEvent(

return new UpdateIndexDataEvent($element, $customFields);
}

public function getRelatedItemsOnUpdateQuery(
ElementInterface $element,
string $operation,
int $operationTime,
bool $includeElement = false
): ?QueryBuilder {
return $this->dbConnection->createQueryBuilder()
->select([
$element->getId(),
"'" . ElementType::ASSET->value . "'",
"'" . IndexName::ASSET->value . "'",
"'$operation'",
"'$operationTime'",
'0',
])
->from('DUAL') // just a dummy query to fit into the query builder interface
->setMaxResults(1);
}
}

0 comments on commit 4f25922

Please sign in to comment.