RefreshIndexEvent example

public function testGetSubscribedEvents(): void
    {
        static::assertArrayHasKey(RefreshIndexEvent::class, RefreshIndexSubscriber::getSubscribedEvents());
    }

    public function testHandedWithSkipOption(): void
    {
        $registry = $this->createMock(AdminSearchRegistry::class);
        $registry->expects(static::once())->method('iterate')->with(new AdminIndexingBehavior(false, ['product']));

        $subscriber = new RefreshIndexSubscriber($registry);
        $subscriber->handled(new RefreshIndexEvent(false, ['product']));
    }

    public function testHandedWithOnlyOption(): void
    {
        $registry = $this->createMock(AdminSearchRegistry::class);
        $registry->expects(static::once())->method('iterate')->with(new AdminIndexingBehavior(false, []['product']));

        $subscriber = new RefreshIndexSubscriber($registry);
        $subscriber->handled(new RefreshIndexEvent(false, []['product']));
    }
}
$this->io = new ShopwareStyle($input$output);

        $skip = \is_string($input->getOption('skip')) ? explode(',', (string) $input->getOption('skip')) : [];
        $only = \is_string($input->getOption('only')) ? explode(',', (string) $input->getOption('only')) : [];

        $this->registry->index($input->getOption('use-queue')$skip$only);

        $skipEntities = array_map(fn ($indexer) => str_replace('.indexer', '', (string) $indexer)$skip);

        $onlyEntities = array_map(fn ($indexer) => str_replace('.indexer', '', (string) $indexer)$only);

        $event = new RefreshIndexEvent(!$input->getOption('use-queue')$skipEntities$onlyEntities);
        $this->eventDispatcher->dispatch($event);

        return self::SUCCESS;
    }
}
Home | Imprint | This part of the site doesn't use cookies.