Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/magento/module-catalog-search/Model/Indexer/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-catalog-search/Model/Indexer/IndexSwitcherProxy.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

namespace Magento\CatalogSearch\Model\Indexer;

use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Search\EngineResolverInterface;

/**
 * Proxy for adapter-specific index switcher
 *
 * @deprecated mysql search engine has been removed
 * @see \Magento\Elasticsearch
 */
class IndexSwitcherProxy implements IndexSwitcherInterface
{
    /**
     * Object Manager instance
     *
     * @var ObjectManagerInterface
     */
    private $objectManager = null;

    /**
     * Instance name to create
     *
     * @var string
     */
    private $handlers;

    /**
     * @var EngineResolverInterface
     */
    private $engineResolver;

    /**
     * Factory constructor
     *
     * @param ObjectManagerInterface $objectManager
     * @param EngineResolverInterface $engineResolver
     * @param string[] $handlers
     */
    public function __construct(
        ObjectManagerInterface $objectManager,
        EngineResolverInterface $engineResolver,
        array $handlers = []
    ) {
        $this->objectManager = $objectManager;
        $this->handlers = $handlers;
        $this->engineResolver = $engineResolver;
    }

    /**
     * @inheritDoc
     *
     * As index switcher is an optional part of the search SPI, it may be not defined by a search engine.
     * It is especially reasonable for search engines with pre-defined indexes declaration (like Sphinx)
     * which cannot create temporary indexes on the fly.
     * That's the reason why this method do nothing for the case
     * when switcher is not defined for a specific search engine.
     */
    public function switchIndex(array $dimensions)
    {
        $currentHandler = $this->engineResolver->getCurrentSearchEngine();
        if (!isset($this->handlers[$currentHandler])) {
            return;
        }
        $this->create($currentHandler)->switchIndex($dimensions);
    }

    /**
     * Create indexer handler
     *
     * @param string $handler
     * @return IndexSwitcherInterface
     */
    private function create($handler)
    {
        $indexSwitcher = $this->objectManager->create($this->handlers[$handler]);

        if (!$indexSwitcher instanceof IndexSwitcherInterface) {
            throw new \InvalidArgumentException(
                $handler . ' index switcher doesn\'t implement ' . IndexSwitcherInterface::class
            );
        }

        return $indexSwitcher;
    }
}

Spamworldpro Mini