Skip to content

Commit

Permalink
provide better error when doctrine/orm is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Feb 5, 2019
1 parent e54bf58 commit 3e59d01
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 3e59d01

Please sign in to comment.