Builds search engine identified by its identifier (the "alias" attribute in the service tag),
resolved for current siteaccess.

@throws \eZ\Bundle\EzPublishCoreBundle\ApiLoader\Exception\InvalidSearchEngine

@return \eZ\Publish\SPI\Persistence\Handler
353908
public function buildSearchEngine()
    {
        $repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig();

        if (
            !(
                isset($repositoryConfig['search']['engine'])
                && isset($this->searchEngines[$repositoryConfig['search']['engine']])
            )
        ) {
            throw new InvalidSearchEngine(
                "Invalid search engine '{$repositoryConfig['search']['engine']}'. " .
                "Could not find a service tagged as 'ezpublish.searchEngine' " .
                "with alias '{$repositoryConfig['search']['engine']}'."
            );
        }

        return $this->searchEngines[$repositoryConfig['search']['engine']];
    }
118391
public function getSearchService()
    {
        if ($this->searchService !== null) {
            return $this->searchService;
        }

        $this->searchService = new SearchService(
            $this,
            $this->searchHandler,
            $this->getDomainMapper(),
            $this->getPermissionCriterionResolver(),
            $this->backgroundIndexer,
            $this->serviceSettings['search']
        );

        return $this->searchService;
    }
894532
public function create() {
		$ssoClient = new \Flowpack\SingleSignOn\Client\Domain\Model\SsoClient();
		if ((string)$this->clientServiceBaseUri === '') {
			throw new Exception('Missing Flowpack.SingleSignOn.Client.client.serviceBaseUri setting', 1351075078);
		}
		$ssoClient->setServiceBaseUri($this->clientServiceBaseUri);
		if ((string)$this->clientPublicKeyFingerprint === '') {
			throw new Exception('Missing Flowpack.SingleSignOn.Client.client.publicKeyFingerprint setting', 1351075159);
		}
		$ssoClient->setPublicKeyFingerprint($this->clientPublicKeyFingerprint);
		return $ssoClient;
	}
528065
public function buildLegacyKernelHandlerCLI()
    {
        $legacyRootDir = $this->legacyRootDir;
        $eventDispatcher = $this->eventDispatcher;
        $container = $this->container;
        $that = $this;

        return static function () use ($legacyRootDir, $container, $eventDispatcher, $that) {
            if (!$that->getCLIHandler()) {
                $currentDir = getcwd();
                chdir($legacyRootDir);

                $legacyParameters = new ParameterBag($container->getParameter('ezpublish_legacy.kernel_handler.cli.options'));
                if ($that->getBuildEventsEnabled()) {
                    $eventDispatcher->dispatch(LegacyEvents::PRE_BUILD_LEGACY_KERNEL, new PreBuildKernelEvent($legacyParameters));
                }

                $that->setCLIHandler(
                    new CLIHandler($legacyParameters->all(), $container->get('ezpublish.siteaccess'), $container)
                );

                chdir($currentDir);
            }

            return $that->getCLIHandler();
        };
    }
738682
static public function getEngine()
    {
        // Get instance if already created.
        $instanceName = "eZSearchPlugin_" . $GLOBALS["eZCurrentAccess"]["name"];
        if ( isset( $GLOBALS[$instanceName] ) )
        {
            return $GLOBALS[$instanceName];
        }

        $ini = eZINI::instance();

        $searchEngineString = 'ezsearch';
        if ( $ini->hasVariable( 'SearchSettings', 'SearchEngine' ) == true )
        {
            $searchEngineString = $ini->variable( 'SearchSettings', 'SearchEngine' );
        }

        $directoryList = array();
        if ( $ini->hasVariable( 'SearchSettings', 'ExtensionDirectories' ) )
        {
            $extensionDirectories = $ini->variable( 'SearchSettings', 'ExtensionDirectories' );
            if ( is_array( $extensionDirectories ) )
            {
                $directoryList = eZExtension::expandedPathList( $extensionDirectories, 'search/plugins' );
            }
        }

        $kernelDir = array( 'kernel/search/plugins' );
        $directoryList = array_merge( $kernelDir, $directoryList );

        foreach( $directoryList as $directory )
        {
            $searchEngineFile = implode( '/', array( $directory, strtolower( $searchEngineString ), strtolower( $searchEngineString ) ) ) . '.php';

            if ( file_exists( $searchEngineFile ) )
            {
                eZDebugSetting::writeDebug( 'kernel-search-ezsearch', 'Loading search engine from ' . $searchEngineFile, 'eZSearch::getEngine' );

                include_once( $searchEngineFile );
                $GLOBALS[$instanceName] = new $searchEngineString();
                return $GLOBALS[$instanceName];
            }
        }

        eZDebug::writeDebug( 'Unable to find the search engine:' . $searchEngineString, 'eZSearch' );
        eZDebug::writeDebug( 'Tried paths: ' . implode( ', ', $directoryList ), 'eZSearch' );
        return false;
    }
645476
public function buildQuery()
    {
        $model = $this->model;
        $query = $model::query();

        // perform joins
        if (is_array($this->join)) {
            foreach ($this->join as $condition) {
                list($joinModel, $column, $foreignKey) = $condition;
                $query->join($joinModel, $column, $foreignKey);
            }
        }

        // sanitze and set the filter
        $filter = $this->parseFilterInput($this->filter);
        $query->where($filter);

        // performs a search using LIKE queries
        // WARNING use sparingly, these queries are expensive
        if (!empty($this->search) && is_string($this->search) && property_exists($model, 'searchableProperties')) {
            $w = [];
            $search = addslashes($this->search);
            foreach ($model::$searchableProperties as $name) {
                $w[] = "`$name` LIKE '%$search%'";
            }

            if (count($w) > 0) {
                $query->where('('.implode(' OR ', $w).')');
            }
        }

        // eager loading
        foreach ($this->expand as $k) {
            $property = $model::getProperty($k);
            if ($property && isset($property['relation'])) {
                if (isset($property['id_property'])) {
                    $query->with($property['id_property']);
                } else {
                    $query->with($k);
                }
            }
        }

        if (isset($this->sort)) {
            $query->sort($this->sort);
        }

        // calculate limit and offset
        $start = ($this->page - 1) * $this->perPage;
        $query->start($start)->limit($this->perPage);

        return $query;
    }
491721
private function buildIndexAction() {
        $api = new Swagger\Api();
        $api->setPath('/' . $this->getClassName());
        $operation = new Swagger\Operation();
        $operation->setMethod('GET');
        $operation->setSummary('Lists all ' . $this->getClassName() . '.');
        $operation->setNotes(
            'Only returns the first 50 by default. Using the actual API you can search by parent fields and any field on the model as opposed to the brief list provided below.'
        );
        $responseMessage = new Swagger\ResponseMessage();
        $responseMessage->setCode(200);
        $responseMessage->setMessage('List of ' . $this->getClassName() . '.');
        $responseMessage->setResponseModel($this->getClassName());
        $operation->addResponseMessage($responseMessage);

        $responseMessage = $this->invalidFieldSpecifiedError();
        $operation->addResponseMessage($responseMessage);

        $responseMessage = $this->notAuthorizedResponse();
        $operation->addResponseMessage($responseMessage);

        $operation->addParameter($this->buildStartParameter());
        $operation->addParameter($this->buildCountParameter());
        $operation->addParameter($this->buildSortParameter());
        $operation->addParameter($this->buildFieldsParameter());
        $searchParameters = $this->buildSearchParameters();
        foreach($searchParameters as $searchParameter) {
            $operation->addParameter($searchParameter);
        }
        $api->addOperation($operation);

        $method = new Object\Method();
        $method->setDescription($api->__toString());
        $method->setReturnType('void');
        $method->setAccess('public');
        $method->setName('indexAction');
        $method->setContent('parent::indexAction();');
        $this->getObject()->addMethod($method);
    }
1224584
public function build(): DispatchSyncEventRequest
	{
		$instance = new DispatchSyncEventRequest();
		if ($this->origin === null) {
			throw new BuilderException('Property [origin] is required.');
		}
		$instance->origin = $this->origin;
		if ($this->registrationId === null) {
			throw new BuilderException('Property [registrationId] is required.');
		}
		$instance->registrationId = $this->registrationId;
		if ($this->tag === null) {
			throw new BuilderException('Property [tag] is required.');
		}
		$instance->tag = $this->tag;
		if ($this->lastChance === null) {
			throw new BuilderException('Property [lastChance] is required.');
		}
		$instance->lastChance = $this->lastChance;
		return $instance;
	}
606930
public function build()
    {
        return $this->subject('Contact Us - ' . config('app.name'))
            ->to($this->contactUs->email, $this->contactUs->fullname)
            ->markdown('titan::emails.contactus_client');
    }
94884
public function getEngine() {
        if (!$this->_engine) {
            $engine = new \Decoda\Engine\PhpEngine();
            $engine->addPath(dirname(__DIR__) . '/templates/');

            $this->setEngine($engine);
        }

        return $this->_engine;
    }
374323
protected function buildQuery()
	{
		$this->setup();

		$query = array();

		// Index always needs to be provided. _all means a cross index search.
		$query['index'] = empty($this->indices) ? '_all' : implode(',', array_values($this->indices));

		// Type is not required, will search in the entire index.
		if (!empty($this->types)) {
			$query['type'] = implode(',', array_values($this->types));
		}

		// Replace Fragments with their raw body.
		$query['body'] = $this->fragmentParser->parse($this->body);

		// Add all query string params, the SDK will only add known params to the URL.
		foreach ($this->queryStringParams as $paramName => $paramValue) {
			$query[$paramName] = $paramValue;
		}

		return $query;
	}
829874
public function build(): SearchInResourceRequest
	{
		$instance = new SearchInResourceRequest();
		if ($this->frameId === null) {
			throw new BuilderException('Property [frameId] is required.');
		}
		$instance->frameId = $this->frameId;
		if ($this->url === null) {
			throw new BuilderException('Property [url] is required.');
		}
		$instance->url = $this->url;
		if ($this->query === null) {
			throw new BuilderException('Property [query] is required.');
		}
		$instance->query = $this->query;
		$instance->caseSensitive = $this->caseSensitive;
		$instance->isRegex = $this->isRegex;
		return $instance;
	}
1022369
public function build(): TrackIndexedDBForOriginRequest
	{
		$instance = new TrackIndexedDBForOriginRequest();
		if ($this->origin === null) {
			throw new BuilderException('Property [origin] is required.');
		}
		$instance->origin = $this->origin;
		return $instance;
	}
217352
public function create()
    {
        if (empty($this->id)) {
            throw new InvalidException('You should set a valid pipeline id');
        }

        if (empty($this->_params['description'])) {
            throw new InvalidException('You should set a valid processor description.');
        }

        if (empty($this->_processors['processors'])) {
            throw new InvalidException('You should set a valid processor of type Elastica\Processor\AbstractProcessor.');
        }

        $endpoint = new Put();
        $endpoint->setID($this->id);
        $endpoint->setBody($this->toArray());

        return $this->requestEndpoint($endpoint);
    }
293350
protected function buildDispatcher()
    {
        $this->app->singleton(
            'Ratchet\Wamp\WampServerInterface',
            Dispatcher::class
        );
        
        return $this->Dispatcher = $this->app->make('Ratchet\Wamp\WampServerInterface', [$this->getSession(), $this->buildKernel(), clone $this->out]);
    }
516800
public function build()
    {
        $input = new IndexInput($this->namespace, $this->indexName, $this->criteria);
        $spec  = new Specification($input, $this->phases, $this->timeout);

        return new IndexMapReduce($spec);
    }
1207665
public function execute()
    {
        $indexIdentifiers = [SessionIndexInterface::INDEX_IDENTIFIER, EventIndexInterface::INDEX_IDENTIFIER];
        foreach ($indexIdentifiers as $indexIdentifier) {
            if (!$this->checkIndexPresence($indexIdentifier)) {
                $this->messageManager->addWarningMessage(
                    "{$indexIdentifier} index does not exist yet. Make sure everything is reindexed."
                );
            }
        }

        /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
        $resultPage = $this->resultPageFactory->create();
        $resultPage->setActiveMenu('Smile_ElasticsuiteAnalytics::search_usage');
        $resultPage->addBreadcrumb(__('Search Engine'), __('Analytics'));
        $resultPage->getConfig()->getTitle()->prepend(__('Search Usage Analytics'));

        return $resultPage;
    }