public function afterGet(\Magento\Search\Model\QueryFactory $queryFactory, \Magento\Search\Model\Query $query)
    {
        if ($query && $query->getQueryText() !== '') {
            $this->searchContext->setCurrentSearchQuery($query);
        }

        return $query;
    }
public function afterGet(\Magento\Search\Model\QueryFactory $queryFactory, \Magento\Search\Model\Query $query)
    {
        if ($query && $query->getQueryText() !== '') {
            $this->searchContext->setCurrentSearchQuery($query);
        }

        return $query;
    }
public function afterGet ( \ Magento \ Search \ Model \ QueryFactory $ queryFactory , \ Magento \ Search \ Model \ Query $ query ) { if ( $ query && $ query -> getQueryText ( ) !== '' ) { $ this -> searchContext -> setCurrentSearchQuery ( $ query ) ; } return $ query ; }
Set the current search query into the Search context after being retrieved.

@SuppressWarnings(PHPMD.UnusedFormalParameter)

@param \Magento\Search\Model\QueryFactory $queryFactory The Query Factory
@param \Magento\Search\Model\Query        $query        The Query

@return \Magento\Search\Model\Query
Set the current search query into the Search context after being retrieved .