Skip to content

Commit

Permalink
Override Bundle::getPath()
Browse files Browse the repository at this point in the history
This is required when the bundle class is not at the root path of the
bundle, which is the case since doctrine#1767
  • Loading branch information
greg0ire committed Mar 15, 2024
1 parent fa3e8e3 commit 4eacd97
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/DoctrineBundle.php
Expand Up @@ -16,6 +16,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Proxy\Autoloader;
use Doctrine\ORM\Proxy\DefaultProxyClassNameResolver;
use ReflectionObject;
use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\DoctrineValidationPass;
use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterEventListenersAndSubscribersPass;
use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterUidTypePass;
Expand All @@ -30,6 +31,7 @@
use function assert;
use function class_exists;
use function clearstatcache;
use function dirname;
use function spl_autoload_unregister;

/** @final since 2.9 */
Expand Down Expand Up @@ -168,4 +170,14 @@ public function shutdown()
public function registerCommands(Application $application)
{
}

public function getPath(): string
{
if (! isset($this->path)) {
$reflected = new ReflectionObject($this);
$this->path = dirname($reflected->getFileName());
}

return $this->path;
}
}

0 comments on commit 4eacd97

Please sign in to comment.