diff --git a/.travis.yml b/.travis.yml index 79910d3b..b2267955 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,12 +12,14 @@ matrix: include: - php: 7.0 env: SYMFONY_VERSION=^3.3 - - php: 7.0 - env: SYMFONY_VERSION=^3.4 - php: 7.0 env: COMPOSER_FLAGS="--prefer-lowest" - php: 7.1 env: SYMFONY_VERSION=^3.4 + - php: 7.2 + env: SYMFONY_VERSION=^3.3 + - php: 7.2 + env: SYMFONY_VERSION=^3.4 - php: 7.2 env: DEPENDENCIES=dev - php: nightly diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e20ca9e..dee716ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,14 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] Nothing yet. +## [0.1.1] - 2017-12-03 +### Fixed + - Changed ORMAdapter autowire to manual to avoid compile time failures when optional + dependencies are missing + ## 0.1.0 - 2017-12-01 ### Added - Basic functionality -[Unreleased]: https://github.com/omines/datatables-bundle/compare/0.1.0...master +[Unreleased]: https://github.com/omines/datatables-bundle/compare/0.1.1...master +[0.1.1]: https://github.com/omines/datatables-bundle/compare/0.1.0...0.1.1 diff --git a/src/Adapter/Doctrine/ORMAdapter.php b/src/Adapter/Doctrine/ORMAdapter.php index 3cd6aa49..2b79e7c9 100644 --- a/src/Adapter/Doctrine/ORMAdapter.php +++ b/src/Adapter/Doctrine/ORMAdapter.php @@ -55,10 +55,14 @@ class ORMAdapter extends AbstractAdapter /** * DoctrineAdapter constructor. * - * @param RegistryInterface $registry + * @param RegistryInterface|null $registry */ - public function __construct(RegistryInterface $registry) + public function __construct(RegistryInterface $registry = null) { + if (null === $registry) { + throw new \LogicException('Install doctrine/doctrine-bundle to use the ORMAdapter'); + } + parent::__construct(); $this->registry = $registry; } diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml index f4609ebb..85687750 100644 --- a/src/Resources/config/services.yaml +++ b/src/Resources/config/services.yaml @@ -6,7 +6,8 @@ services: # Register default adapters via autoconfig/autowire Omines\DataTablesBundle\Adapter\ArrayAdapter: ~ - Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapter: ~ + Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapter: + arguments: ['@?doctrine'] Omines\DataTablesBundle\DataTableFactory: arguments: ['%datatables.config%', '@datatables.renderer'] diff --git a/tests/Unit/Adapter/DoctrineTest.php b/tests/Unit/Adapter/DoctrineTest.php index 44be842d..3dd33da7 100644 --- a/tests/Unit/Adapter/DoctrineTest.php +++ b/tests/Unit/Adapter/DoctrineTest.php @@ -15,6 +15,7 @@ use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; use Omines\DataTablesBundle\Adapter\Doctrine\ORM\SearchCriteriaProvider; +use Omines\DataTablesBundle\Adapter\Doctrine\ORMAdapter; use Omines\DataTablesBundle\Column\TextColumn; use Omines\DataTablesBundle\DataTable; use PHPUnit\Framework\TestCase; @@ -53,4 +54,13 @@ public function testSearchCriteriaProvider() // As this is buggy right now ignore the result $this->assertTrue(true); } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage doctrine/doctrine-bundle + */ + public function testORMAdapterRequiresDependency() + { + (new ORMAdapter()); + } }