Skip to content

Commit 47e4a40

Browse files
committed
Wire ORMAdapter manually instead of using autowire
1 parent ab38d22 commit 47e4a40

File tree

5 files changed

+29
-6
lines changed

5 files changed

+29
-6
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ matrix:
1212
include:
1313
- php: 7.0
1414
env: SYMFONY_VERSION=^3.3
15-
- php: 7.0
16-
env: SYMFONY_VERSION=^3.4
1715
- php: 7.0
1816
env: COMPOSER_FLAGS="--prefer-lowest"
1917
- php: 7.1
2018
env: SYMFONY_VERSION=^3.4
19+
- php: 7.2
20+
env: SYMFONY_VERSION=^3.3
21+
- php: 7.2
22+
env: SYMFONY_VERSION=^3.4
2123
- php: 7.2
2224
env: DEPENDENCIES=dev
2325
- php: nightly

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55
## [Unreleased]
66
Nothing yet.
77

8+
## [0.1.1] - 2017-12-03
9+
### Fixed
10+
- Changed ORMAdapter autowire to manual to avoid compile time failures when optional
11+
dependencies are missing
12+
813
## 0.1.0 - 2017-12-01
914
### Added
1015
- Basic functionality
1116

12-
[Unreleased]: https://github.com/omines/datatables-bundle/compare/0.1.0...master
17+
[Unreleased]: https://github.com/omines/datatables-bundle/compare/0.1.1...master
18+
[0.1.1]: https://github.com/omines/datatables-bundle/compare/0.1.0...0.1.1

src/Adapter/Doctrine/ORMAdapter.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@ class ORMAdapter extends AbstractAdapter
5555
/**
5656
* DoctrineAdapter constructor.
5757
*
58-
* @param RegistryInterface $registry
58+
* @param RegistryInterface|null $registry
5959
*/
60-
public function __construct(RegistryInterface $registry)
60+
public function __construct(RegistryInterface $registry = null)
6161
{
62+
if (null === $registry) {
63+
throw new \LogicException('Install doctrine/doctrine-bundle to use the ORMAdapter');
64+
}
65+
6266
parent::__construct();
6367
$this->registry = $registry;
6468
}

src/Resources/config/services.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ services:
66

77
# Register default adapters via autoconfig/autowire
88
Omines\DataTablesBundle\Adapter\ArrayAdapter: ~
9-
Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapter: ~
9+
Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapter:
10+
arguments: ['@?doctrine']
1011

1112
Omines\DataTablesBundle\DataTableFactory:
1213
arguments: ['%datatables.config%', '@datatables.renderer']

tests/Unit/Adapter/DoctrineTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Doctrine\ORM\Query;
1616
use Doctrine\ORM\QueryBuilder;
1717
use Omines\DataTablesBundle\Adapter\Doctrine\ORM\SearchCriteriaProvider;
18+
use Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapter;
1819
use Omines\DataTablesBundle\Column\TextColumn;
1920
use Omines\DataTablesBundle\DataTable;
2021
use PHPUnit\Framework\TestCase;
@@ -53,4 +54,13 @@ public function testSearchCriteriaProvider()
5354
// As this is buggy right now ignore the result
5455
$this->assertTrue(true);
5556
}
57+
58+
/**
59+
* @expectedException \LogicException
60+
* @expectedExceptionMessage doctrine/doctrine-bundle
61+
*/
62+
public function testORMAdapterRequiresDependency()
63+
{
64+
(new ORMAdapter());
65+
}
5666
}

0 commit comments

Comments
 (0)