Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimplePrevNextViewHelper gives error if number of items is 0 #41

Closed
stat1x opened this issue Oct 6, 2015 · 1 comment
Closed

SimplePrevNextViewHelper gives error if number of items is 0 #41

stat1x opened this issue Oct 6, 2015 · 1 comment

Comments

@stat1x
Copy link

stat1x commented Oct 6, 2015

Without the test added below an error occurs if the number of news in the storage equals 1.

protected function mapResultToObjects(array $result) {
        $out = $tmp = array();
        $count = count($result);

        if($count > 0) {
            switch ($count) {
                case 3:
                    $tmp['prev'] = $result[0];
                    $tmp['next'] = $result[2];
                    break;
                case 2:
                    $tmp['prev'] = $result[0];
                    break;
                case 1:
                    $tmp['next'] = $result[0];
                    break;
                default:
                    throw new \UnexpectedValueException(sprintf('Unexpected count of "%s" which is not implemented!', $count));
            }

            foreach ($tmp as $_id => $single) {
                $out[$_id] = $this->getObject($single['uid']);
            }
        }

        return $out;
    }
@georgringer
Copy link
Owner

Fixed in meantime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants