Skip to content

Commit

Permalink
Merge pull request #919 from xabbuh/issue-908
Browse files Browse the repository at this point in the history
provide better error when doctrine/orm is missing
  • Loading branch information
alcaeus committed Feb 6, 2019
2 parents e54bf58 + e10c26a commit a7fa6ef
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions DependencyInjection/Configuration.php
Expand Up @@ -2,11 +2,13 @@

namespace Doctrine\Bundle\DoctrineBundle\DependencyInjection;

use Doctrine\ORM\EntityManager;
use ReflectionClass;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\DependencyInjection\Exception\LogicException;

/**
* This class contains the configuration information for the bundle
Expand Down Expand Up @@ -307,6 +309,10 @@ private function addOrmSection(ArrayNodeDefinition $node)
->arrayNode('orm')
->beforeNormalization()
->ifTrue(static function ($v) {
if (! empty($v) && ! class_exists(EntityManager::class)) {
throw new LogicException('The doctrine/orm package is required when the doctrine.orm config is set.');
}

return $v === null || (is_array($v) && ! array_key_exists('entity_managers', $v) && ! array_key_exists('entity_manager', $v));
})
->then(static function ($v) {
Expand Down

0 comments on commit a7fa6ef

Please sign in to comment.