module/FzyCommon/src/FzyCommon/Service/Search/Base.php
public function search(Params $params, $asEntity = false)
    {
        // hook to prepare for search
        $this->prepareSearch($params);

        // set limit/offset
        $this->setMetaData($params);

        if ($this->isSingular($params)) {
            try {
                $result = array($this->identitySearch($params));
                $this->setTotal(1);
            } catch (NotFound $e) {
                // nothing found
                $result = array();
                $this->setTotal(0);
            }
        } else {
            $result = $this->querySearch($params);
        }

        $this->preProcess($params, $result);
        $processed = array();
        foreach ($result as $entity) {
            $processed[] = $this->process($entity, $params, $result, $asEntity);
        }

        $this->postProcess($params, $result, $processed);
        $this->results = $processed;

        return $this;
    }
public function search(Params $params, $asEntity = false)
    {
        // hook to prepare for search
        $this->prepareSearch($params);

        // set limit/offset
        $this->setMetaData($params);

        if ($this->isSingular($params)) {
            try {
                $result = array($this->identitySearch($params));
                $this->setTotal(1);
            } catch (NotFound $e) {
                // nothing found
                $result = array();
                $this->setTotal(0);
            }
        } else {
            $result = $this->querySearch($params);
        }

        $this->preProcess($params, $result);
        $processed = array();
        foreach ($result as $entity) {
            $processed[] = $this->process($entity, $params, $result, $asEntity);
        }

        $this->postProcess($params, $result, $processed);
        $this->results = $processed;

        return $this;
    }
Main lifecycle of this service;
Using the passed in $params value
@param  Params $params
@param  bool   $asEntity - keep result as entity
@return $this