Skip to content

Commit

Permalink
Stop using deprecated SourceIteratorInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored and jordisala1991 committed Feb 13, 2022
1 parent 2246f89 commit 3d9534c
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 16 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
strategy:
matrix:
php-version:
- '7.3'
- '7.4'
- '8.0'
- '8.1'
Expand All @@ -37,7 +36,7 @@ jobs:
symfony-require: ['']
variant: [normal]
include:
- php-version: '7.3'
- php-version: '7.4'
dependencies: lowest
allowed-to-fail: false
variant: normal
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],
"homepage": "https://docs.sonata-project.org/projects/SonataAdminBundle",
"require": {
"php": "^7.3 || ^8.0",
"php": "^7.4 || ^8.0",
"ext-json": "*",
"doctrine/collections": "^1.6",
"doctrine/common": "^3.0",
Expand All @@ -36,7 +36,7 @@
"psr/log": "^1.1 || ^2.0 || ^3.0",
"sonata-project/block-bundle": "^4.7",
"sonata-project/doctrine-extensions": "^1.8",
"sonata-project/exporter": "^2.1",
"sonata-project/exporter": "^2.11",
"sonata-project/form-extensions": "^1.7.1",
"sonata-project/twig-extensions": "^1.4.1",
"symfony/asset": "^4.4 || ^5.3 || ^6.0",
Expand Down
3 changes: 1 addition & 2 deletions src/Admin/AbstractAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\AdminBundle\Util\Instantiator;
use Sonata\AdminBundle\Util\ParametersManipulator;
use Sonata\Exporter\Source\SourceIteratorInterface;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
Expand Down Expand Up @@ -370,7 +369,7 @@ final public function getExportFields(): array
return $fields;
}

final public function getDataSourceIterator(): SourceIteratorInterface
final public function getDataSourceIterator(): \Iterator
{
$datagrid = $this->getDatagrid();
$datagrid->buildPager();
Expand Down
6 changes: 4 additions & 2 deletions src/Admin/AdminInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use Sonata\AdminBundle\FieldDescription\FieldDescriptionInterface;
use Sonata\AdminBundle\FieldDescription\FieldDescriptionRegistryInterface;
use Sonata\AdminBundle\Object\MetadataInterface;
use Sonata\Exporter\Source\SourceIteratorInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -247,7 +246,10 @@ public function getExportFormats(): array;
*/
public function getExportFields(): array;

public function getDataSourceIterator(): SourceIteratorInterface;
/**
* @return \Iterator<array<mixed>>
*/
public function getDataSourceIterator(): \Iterator;

/**
* Call before the batch action, allow you to alter the query and the idx.
Expand Down
5 changes: 3 additions & 2 deletions src/Exporter/DataSourceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
namespace Sonata\AdminBundle\Exporter;

use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
use Sonata\Exporter\Source\SourceIteratorInterface;

interface DataSourceInterface
{
/**
* @param string[] $fields
*
* @return \Iterator<array<mixed>>
*/
public function createIterator(ProxyQueryInterface $query, array $fields): SourceIteratorInterface;
public function createIterator(ProxyQueryInterface $query, array $fields): \Iterator;
}
3 changes: 1 addition & 2 deletions tests/Admin/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
use Sonata\AdminBundle\Translator\NoopLabelTranslatorStrategy;
use Sonata\AdminBundle\Translator\UnderscoreLabelTranslatorStrategy;
use Sonata\Doctrine\Adapter\AdapterInterface;
use Sonata\Exporter\Source\SourceIteratorInterface;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Form\FormFactory;
Expand Down Expand Up @@ -2231,7 +2230,7 @@ public function testGetDataSourceIterator(): void
$modelManager = $this->createMock(ModelManagerInterface::class);
$dataSource = $this->createMock(DataSourceInterface::class);
$proxyQuery = $this->createStub(ProxyQueryInterface::class);
$sourceIterator = $this->createStub(SourceIteratorInterface::class);
$sourceIterator = $this->createStub(\Iterator::class);

$admin = new PostAdmin();
$admin->setModelClass(Post::class);
Expand Down
3 changes: 1 addition & 2 deletions tests/App/Exporter/DataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
use Sonata\AdminBundle\Exporter\DataSourceInterface;
use Sonata\Exporter\Source\ArraySourceIterator;
use Sonata\Exporter\Source\SourceIteratorInterface;

final class DataSource implements DataSourceInterface
{
public function createIterator(ProxyQueryInterface $query, array $fields): SourceIteratorInterface
public function createIterator(ProxyQueryInterface $query, array $fields): \Iterator
{
return new ArraySourceIterator([]);
}
Expand Down
3 changes: 1 addition & 2 deletions tests/Controller/CRUDControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
use Sonata\AdminBundle\Tests\Fixtures\Util\DummyDomainObject;
use Sonata\AdminBundle\Util\AdminObjectAclManipulator;
use Sonata\Exporter\Exporter;
use Sonata\Exporter\Source\SourceIteratorInterface;
use Sonata\Exporter\Writer\JsonWriter;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand Down Expand Up @@ -2575,7 +2574,7 @@ public function testExportAction(): void
->method('getClass')
->willReturn(\stdClass::class);

$dataSourceIterator = $this->createMock(SourceIteratorInterface::class);
$dataSourceIterator = $this->createMock(\Iterator::class);

$this->admin->expects(static::once())
->method('getDataSourceIterator')
Expand Down

0 comments on commit 3d9534c

Please sign in to comment.