finishIndexer example

/** * @internal */
    public function runRegisteredIndexers(): void
    {
        $queuedIndexers = $this->indexerQueuer->getIndexers();

        if (empty($queuedIndexers)) {
            return;
        }

        $this->indexerQueuer->finishIndexer(array_keys($queuedIndexers));

        foreach ($queuedIndexers as $indexerName => $options) {
            $indexer = $this->indexerRegistry->getIndexer($indexerName);

            if ($indexer === null) {
                continue;
            }

            // If we don't have any required indexer, schedule all             if ($options === []) {
                $this->indexerRegistry->sendIndexingMessage([$indexerName]);

                
public function testOldEntriesCanBeFinished(): void
    {
        $connection = $this->getContainer()->get(Connection::class);
        $connection->insert('system_config', [
            'id' => Uuid::randomBytes(),
            'configuration_key' => IndexerQueuer::INDEXER_KEY,
            'configuration_value' => json_encode(['_value' => ['test.indexer' => 1]]),
            'created_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ]);

        $queuer = new IndexerQueuer($connection);
        $queuer->finishIndexer(['test.indexer']);

        static::assertSame([]$queuer->getIndexers());
    }

    public function testWithOldEntriesAndNewCanBeFinished(): void
    {
        $connection = $this->getContainer()->get(Connection::class);
        $connection->insert('system_config', [
            'id' => Uuid::randomBytes(),
            'configuration_key' => IndexerQueuer::INDEXER_KEY,
            'configuration_value' => json_encode(['_value' => ['test.indexer' => 1]]),
            
Home | Imprint | This part of the site doesn't use cookies.