getRefreshIndices example



        $this->swapAlias($indices);
    }

    public function refresh(EntityWrittenContainerEvent $event): void
    {
        if (!$this->adminEsHelper->getEnabled() || !$this->isIndexedEntityWritten($event)) {
            return;
        }

        if ($this->adminEsHelper->getRefreshIndices()) {
            $this->refreshIndices();
        }

        /** @var array<string, string> $indices */
        $indices = $this->connection->fetchAllKeyValue('SELECT `alias`, `index` FROM admin_elasticsearch_index_task');

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

        foreach ($this->indexer as $indexer) {
            

class AdminElasticsearchHelperTest extends TestCase
{
    /** * @dataProvider searchHelperProvider */
    public function testSearchHelper(bool $adminEsEnabled, bool $refreshIndices, string $adminIndexPrefix): void
    {
        $searchHelper = new AdminElasticsearchHelper($adminEsEnabled$refreshIndices$adminIndexPrefix);

        static::assertEquals($adminEsEnabled$searchHelper->getEnabled());
        static::assertEquals($refreshIndices$searchHelper->getRefreshIndices());
        static::assertEquals($adminIndexPrefix$searchHelper->getPrefix());
        static::assertEquals($adminIndexPrefix . '-promotion-listing', $searchHelper->getIndex('promotion-listing'));
    }

    public function testSetEnable(): void
    {
        $searchHelper = new AdminElasticsearchHelper(false, false, 'sw-admin');

        static::assertFalse($searchHelper->getEnabled());
        static::assertFalse($searchHelper->getRefreshIndices());
        static::assertEquals('sw-admin', $searchHelper->getPrefix());
        
Home | Imprint | This part of the site doesn't use cookies.