queryFactory = $queryFactory; $this->string = $string; } /** * Prepare Query object based on search text * * @param ContextInterface $context * @param string $queryText * @throws NoSuchEntityException * @return Query */ public function prepare(ContextInterface $context, string $queryText) : Query { $query = $this->queryFactory->create(); $maxQueryLength = (int) $query->getMaxQueryLength(); if ($maxQueryLength && $this->string->strlen($queryText) > $maxQueryLength) { $queryText = $this->string->substr($queryText, 0, $maxQueryLength); } $query->setQueryText($queryText); $store = $context->getExtensionAttributes()->getStore(); $query->setStoreId($store->getId()); return $query; } }