Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of casting an array of entities to a collection
<?php
namespace App\Entity;
use ArrayIterator;
class UserCollection extends ArrayIterator
{
}
<?php
$users = new UserCollection($userRepository->findAll());
@weierophinney

This comment has been minimized.

Copy link
Owner Author

weierophinney commented Jun 5, 2018

Note the change from extending Zend\Paginator\Paginator to extending ArrayIterator.

If you want to do pagination, you'll need to use something like the https://github.com/doctrine/DoctrineORMModule/blob/master/src/DoctrineORMModule/Paginator/Adapter/DoctrinePaginator.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.