Skip to content

Commit

Permalink
only load compiler pass for odm when odm is available
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Jul 17, 2013
1 parent 860db72 commit c0e7b61
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
19 changes: 10 additions & 9 deletions Command/DoctrineCommandHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@

namespace Doctrine\Bundle\PHPCRBundle\Command;

use Doctrine\ODM\PHPCR\Tools\Console\Helper\DocumentManagerHelper;
use PHPCR\Util\Console\Helper\PhpcrHelper;
use Symfony\Component\Console\Application;

use Jackalope\Tools\Console\Helper\DoctrineDbalHelper;
use Jackalope\Tools\Console\Helper\JackrabbitHelper;
use Jackalope\Transport\DoctrineDBAL\Client;
use Jackalope\Transport\DoctrineDBAL\Client as DbalClient;
use Jackalope\Transport\Jackrabbit\Client as JackrabbitClient;
use Jackalope\Session;

/**
* Provides some helper and convenience methods to configure doctrine commands in the context of bundles
* and multiple sessions/document managers.
* Provides some helper and convenience methods to configure doctrine commands
* in the context of bundles and multiple sessions/document managers.
*
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
Expand All @@ -40,14 +42,13 @@ static public function setApplicationPHPCRSession(Application $application, $con
$service = null === $connName ? 'doctrine_phpcr.session' : 'doctrine_phpcr.'.$connName.'_session';
$session = $application->getKernel()->getContainer()->get($service);
$helperSet = $application->getHelperSet();
if (class_exists('Doctrine\\ODM\\PHPCR\\Version')) {
$helperSet->set(new \Doctrine\ODM\PHPCR\Tools\Console\Helper\DocumentManagerHelper($session));
if (class_exists('Doctrine\ODM\PHPCR\Version')) {
$helperSet->set(new DocumentManagerHelper($session));
} else {
$helperSet->set(new \PHPCR\Util\Console\Helper\PhpcrHelper($session));

$helperSet->set(new PhpcrHelper($session));
}

if ($session instanceof Session && $session->getTransport() instanceof Client) {
if ($session instanceof Session && $session->getTransport() instanceof DbalClient) {
$helperSet->set(new DoctrineDBALHelper($session->getTransport()->getConnection()));
}
}
Expand Down
6 changes: 4 additions & 2 deletions DoctrinePHPCRBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public function build(ContainerBuilder $container)

$container->addCompilerPass(new MigratorPass());
$container->addCompilerPass(new InitializerPass());
$container->addCompilerPass(new RegisterEventListenersAndSubscribersPass('doctrine_phpcr.sessions', 'doctrine_phpcr.odm.%s_session.event_manager', 'doctrine_phpcr'), PassConfig::TYPE_BEFORE_OPTIMIZATION);
if (class_exists('Doctrine\ODM\PHPCR\Version')) {
$container->addCompilerPass(new RegisterEventListenersAndSubscribersPass('doctrine_phpcr.sessions', 'doctrine_phpcr.odm.%s_session.event_manager', 'doctrine_phpcr'), PassConfig::TYPE_BEFORE_OPTIMIZATION);
}
}

/**
Expand All @@ -53,7 +55,7 @@ public function registerCommands(Application $application)
{
parent::registerCommands($application);

if (class_exists('Doctrine\\ODM\\PHPCR\\Version')) {
if (class_exists('Doctrine\ODM\PHPCR\Version')) {
$application->add(new InfoDoctrineCommand());
$application->add(new RepositoryInitCommand());
}
Expand Down
2 changes: 1 addition & 1 deletion Migrator/AbstractMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
abstract class AbstractMigrator extends TraversingItemVisitor implements MigratorInterface
{
/**
* @var PHPCR\SessionInterface
* @var SessionInterface
*/
protected $session;

Expand Down

0 comments on commit c0e7b61

Please sign in to comment.