protected function getActiveRecordCriteriaByName($serviceLocator, $name)
    {
        $criteria = $serviceLocator->get($name);
        if (!$criteria instanceof AbstractCriteria) {
            throw new Exception\ServiceNotCreatedException(sprintf(
                'Instance of type %s is invalid; must implement %s',
                (is_object($criteria) ? get_class($criteria) : gettype($criteria)),
                AbstractCriteria::class
            ));
        }
        return $criteria;
    }