public function createDocumentManager(array $paths = null)
 {
     $reader = new \Doctrine\Common\Annotations\AnnotationReader();
     $reader->addGlobalIgnoredName('group');
     if (empty($paths)) {
         $paths = array(__DIR__ . "/../../Models");
     }
     $metaDriver = new AnnotationDriver($reader, $paths);
     $factoryclass = isset($GLOBALS['DOCTRINE_PHPCR_FACTORY']) ? $GLOBALS['DOCTRINE_PHPCR_FACTORY'] : '\\Jackalope\\RepositoryFactoryJackrabbit';
     if ($factoryclass === '\\Jackalope\\RepositoryFactoryDoctrineDBAL') {
         $params = array();
         foreach ($GLOBALS as $key => $value) {
             if (0 === strpos($key, 'jackalope.doctrine.dbal.')) {
                 $params[substr($key, strlen('jackalope.doctrine.dbal.'))] = $value;
             }
         }
         if (isset($params['username'])) {
             $params['user'] = $params['username'];
         }
         $GLOBALS['jackalope.doctrine_dbal_connection'] = \Doctrine\DBAL\DriverManager::getConnection($params);
     }
     $parameters = array_intersect_key($GLOBALS, $factoryclass::getConfigurationKeys());
     // factory will return null if it gets unknown parameters
     $repository = $factoryclass::getRepository($parameters);
     $this->assertNotNull($repository, 'There is an issue with your parameters: ' . var_export(array_keys($parameters), true));
     $workspace = isset($GLOBALS['DOCTRINE_PHPCR_WORKSPACE']) ? $GLOBALS['DOCTRINE_PHPCR_WORKSPACE'] : 'tests';
     $user = isset($GLOBALS['DOCTRINE_PHPCR_USER']) ? $GLOBALS['DOCTRINE_PHPCR_USER'] : '';
     $pass = isset($GLOBALS['DOCTRINE_PHPCR_PASS']) ? $GLOBALS['DOCTRINE_PHPCR_PASS'] : '';
     $credentials = new \PHPCR\SimpleCredentials($user, $pass);
     $session = $repository->login($credentials, $workspace);
     $this->sessions[] = $session;
     $config = new \Doctrine\ODM\PHPCR\Configuration();
     $config->setMetadataDriverImpl($metaDriver);
     return DocumentManager::create($session, $config);
 }
 protected function getMockDocumentManager(EventManager $evm = null)
 {
     $config = new \Doctrine\ODM\PHPCR\Configuration();
     $config->setMetadataDriverImpl($this->getMetadataDriverImplementation());
     $this->dm = DocumentManager::create($this->getSession(), $config, $evm ?: $this->getEventManager());
     return $this->dm;
 }
 protected function setUp()
 {
     $params = array('driver' => 'pdo_mysql', 'host' => 'localhost', 'user' => 'root', 'password' => 'testmachine', 'dbname' => 'v_products_tests');
     $workspace = 'default';
     $user = '******';
     $pass = '******';
     $dbConn = \Doctrine\DBAL\DriverManager::getConnection($params);
     $parameters = array('jackalope.doctrine_dbal_connection' => $dbConn);
     /**
             $schema = RepositorySchema::create();
             foreach ($schema->toSql($dbConn->getDatabasePlatform()) as $sql) {
                 $dbConn->exec($sql);
             } */
     $repositoryFactory = new \Jackalope\RepositoryFactoryDoctrineDBAL();
     $repository = $repositoryFactory->getRepository($parameters);
     $credentials = new \PHPCR\SimpleCredentials(null, null);
     $session = $repository->login($credentials, $workspace);
     $locatorXml = new SymfonyFileLocator(array(__DIR__ . '/../../../lib/Vespolina/Product/Mapping' => 'Vespolina\\Entity\\Product', __DIR__ . '/../../../vendor/vespolina/pricing/lib/Vespolina/Pricing/Mapping' => 'Vespolina\\Entity\\Pricing', __DIR__ . '/../../../vendor/vespolina/taxonomy/lib/Vespolina/Taxonomy/Mapping' => 'Vespolina\\Entity\\Taxonomy'), '.phpcr.xml');
     $xmlDriver = new XmlDriver($locatorXml);
     $config = new \Doctrine\ODM\PHPCR\Configuration();
     $config->setMetadataDriverImpl($xmlDriver);
     $config->setMetadataCacheImpl(new ArrayCache());
     $config->setAutoGenerateProxyClasses(true);
     $documentManager = \Doctrine\ODM\PHPCR\DocumentManager::create($session, $config);
     $this->productGateway = new ProductDoctrinePHPCRGateway($documentManager, 'Vespolina\\Entity\\Product\\Product');
     $this->taxonomyGateway = new TaxonomyPHPCRGateway($documentManager, 'Vespolina\\Entity\\Taxonomy\\TaxonomyNode', '/');
     $this->taxonomyRootNode = $documentManager->find(null, '/');
     parent::setUp();
 }
 protected function getAnnotationDriver()
 {
     AnnotationRegistry::registerFile($this->app['path.base'] . '/vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/DoctrineAnnotations.php');
     $reader = new AnnotationReader();
     $driver = new AnnotationDriver($reader, [$this->app['path.base'] . '/app/']);
     $config = new \Doctrine\ODM\PHPCR\Configuration();
     $config->setMetadataDriverImpl($driver);
     $this->app->singleton('phpcr.manager', function () use($config) {
         return DocumentManager::create($this->app->make('phpcr.session'), $config);
     });
     return $driver;
 }
 /**
  * Gets the 'doctrine_phpcr.odm.default_document_manager' service.
  *
  * This service is shared.
  * This method always returns the same instance of the service.
  *
  * @return \Doctrine\ODM\PHPCR\DocumentManager A Doctrine\ODM\PHPCR\DocumentManager instance.
  */
 protected function getDoctrinePhpcr_Odm_DefaultDocumentManagerService()
 {
     $a = $this->get('annotation_reader');
     $b = new \Doctrine\Common\Cache\ArrayCache();
     $b->setNamespace('sf2phpcr_default_8abfb5439f3e3c6366a9a2a7d225b51607df7dd909070cd38fddb5e661b6f197');
     $c = new \Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver($a, array(0 => $this->targetDirs[3] . '/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/Document', 1 => $this->targetDirs[3] . '/vendor/sonata-project/user-bundle/Document', 2 => $this->targetDirs[3] . '/src/Acme/BasicCmsBundle/Document', 3 => $this->targetDirs[3] . '/src/Application/Sonata/UserBundle/Document', 4 => $this->targetDirs[3] . '/vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Document'));
     $d = new \Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator(array($this->targetDirs[3] . '/vendor/symfony-cmf/routing-bundle/Resources/config/doctrine-model' => 'Symfony\\Cmf\\Bundle\\RoutingBundle\\Model', $this->targetDirs[3] . '/vendor/symfony-cmf/routing-bundle/Resources/config/doctrine-phpcr' => 'Symfony\\Cmf\\Bundle\\RoutingBundle\\Doctrine\\Phpcr'), '.phpcr.xml');
     $e = new \Doctrine\ODM\PHPCR\Mapping\Driver\XmlDriver($d);
     $f = new \Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator(array($this->targetDirs[3] . '/vendor/symfony-cmf/menu-bundle/Resources/config/doctrine-model' => 'Symfony\\Cmf\\Bundle\\MenuBundle\\Model', $this->targetDirs[3] . '/vendor/symfony-cmf/menu-bundle/Resources/config/doctrine-phpcr' => 'Symfony\\Cmf\\Bundle\\MenuBundle\\Doctrine\\Phpcr'), '.phpcr.xml');
     $g = new \Doctrine\ODM\PHPCR\Mapping\Driver\XmlDriver($f);
     $h = new \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain();
     $h->addDriver($c, 'FOS\\UserBundle\\Document');
     $h->addDriver($c, 'Sonata\\UserBundle\\Document');
     $h->addDriver($c, 'Acme\\BasicCmsBundle\\Document');
     $h->addDriver($c, 'Application\\Sonata\\UserBundle\\Document');
     $h->addDriver($c, 'Doctrine\\ODM\\PHPCR\\Document');
     $h->addDriver(new \Doctrine\ODM\PHPCR\Mapping\Driver\XmlDriver(new \Doctrine\Common\Persistence\Mapping\Driver\DefaultFileLocator(array(0 => $this->targetDirs[3] . '/vendor/symfony-cmf/routing-bundle/Resources/config/doctrine-base'), '.phpcr.xml')), 'Symfony\\Component\\Routing');
     $h->addDriver($e, 'Symfony\\Cmf\\Bundle\\RoutingBundle\\Model');
     $h->addDriver($e, 'Symfony\\Cmf\\Bundle\\RoutingBundle\\Doctrine\\Phpcr');
     $h->addDriver(new \Doctrine\ODM\PHPCR\Mapping\Driver\XmlDriver(new \Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator(array($this->targetDirs[3] . '/vendor/symfony-cmf/routing-auto-bundle/Resources/config/doctrine-model' => 'Symfony\\Cmf\\Bundle\\RoutingAutoBundle\\Model'), '.phpcr.xml')), 'Symfony\\Cmf\\Bundle\\RoutingAutoBundle\\Model');
     $h->addDriver($g, 'Symfony\\Cmf\\Bundle\\MenuBundle\\Model');
     $h->addDriver($g, 'Symfony\\Cmf\\Bundle\\MenuBundle\\Doctrine\\Phpcr');
     $i = new \Doctrine\ODM\PHPCR\Configuration();
     $i->setDocumentNamespaces(array('FOSUserBundle' => 'FOS\\UserBundle\\Document', 'SonataUserBundle' => 'Sonata\\UserBundle\\Document', 'AcmeBasicCmsBundle' => 'Acme\\BasicCmsBundle\\Document', 'ApplicationSonataUserBundle' => 'Application\\Sonata\\UserBundle\\Document', '__PHPCRODM__' => 'Doctrine\\ODM\\PHPCR\\Document'));
     $i->setMetadataCacheImpl($b);
     $i->setMetadataDriverImpl($h, false);
     $i->setProxyDir(__DIR__ . '/doctrine/PHPCRProxies');
     $i->setProxyNamespace('PHPCRProxies');
     $i->setAutoGenerateProxyClasses(true);
     $i->setClassMetadataFactoryName('Doctrine\\ODM\\PHPCR\\Mapping\\ClassMetadataFactory');
     $i->setDefaultRepositoryClassName('Doctrine\\ODM\\PHPCR\\DocumentRepository');
     $i->addDocumentNamespace('CmfRoutingBundle', 'Symfony\\Cmf\\Bundle\\RoutingBundle\\Doctrine\\Phpcr');
     $i->addDocumentNamespace('CmfRoutingAutoBundle', 'Symfony\\Cmf\\Bundle\\RoutingAutoBundle\\Model');
     $i->addDocumentNamespace('CmfMenuBundle', 'Symfony\\Cmf\\Bundle\\MenuBundle\\Doctrine\\Phpcr');
     $j = new \Symfony\Bridge\Doctrine\ContainerAwareEventManager($this);
     $j->addEventSubscriber($this->get('cmf_core.persistence.phpcr.non_translatable_metadata_listener'));
     $j->addEventListener(array(0 => 'postLoad', 1 => 'postPersist', 2 => 'postMove'), $this->get('cmf_routing.phpcrodm_route_idprefix_listener'));
     $j->addEventListener(array(0 => 'onFlush', 1 => 'endFlush'), $this->get('cmf_routing_auto.phpcrodm_auto_route_listener'));
     return $this->services['doctrine_phpcr.odm.default_document_manager'] = new \Doctrine\ODM\PHPCR\DocumentManager($this->get('doctrine_phpcr.default_session'), $i, $j);
 }
Пример #6
0
 /**
  * Gets the 'doctrine_phpcr.odm.default_document_manager' service.
  *
  * This service is shared.
  * This method always returns the same instance of the service.
  *
  * @return Doctrine\ODM\PHPCR\DocumentManager A Doctrine\ODM\PHPCR\DocumentManager instance.
  */
 protected function getDoctrinePhpcr_Odm_DefaultDocumentManagerService()
 {
     $a = $this->get('annotation_reader');
     $b = new \Doctrine\Common\Cache\ArrayCache();
     $b->setNamespace('sf2phpcr_default_1f474d7255df8ad758b666714222d890');
     $c = new \Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver($a, array(0 => '/home/markus/development/php.labs/symfony/src/Mtol/TodoBundle/Document', 1 => '/home/markus/development/php.labs/symfony/vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Document'));
     $d = new \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain();
     $d->addDriver($c, 'Mtol\\TodoBundle\\Document');
     $d->addDriver($c, 'Doctrine\\ODM\\PHPCR\\Document');
     $e = new \Doctrine\ODM\PHPCR\Configuration();
     $e->setDocumentNamespaces(array('MtolTodoBundle' => 'Mtol\\TodoBundle\\Document', '__PHPCRODM__' => 'Doctrine\\ODM\\PHPCR\\Document'));
     $e->setMetadataCacheImpl($b);
     $e->setMetadataDriverImpl($d, false);
     $e->setProxyDir('/home/markus/development/php.labs/symfony/app/cache/dev/doctrine/PHPCRProxies');
     $e->setProxyNamespace('PHPCRProxies');
     $e->setAutoGenerateProxyClasses(true);
     return $this->services['doctrine_phpcr.odm.default_document_manager'] = new \Doctrine\ODM\PHPCR\DocumentManager($this->get('doctrine_phpcr.default_session'), $e, new \Symfony\Bridge\Doctrine\ContainerAwareEventManager($this));
 }
 public function createDocumentManager(array $paths = null)
 {
     $reader = new AnnotationReader();
     $reader->addGlobalIgnoredName('group');
     if (empty($paths)) {
         $paths = array(__DIR__ . "/../../../Models");
     }
     $metaDriver = new PhpcrAnnotationDriver($reader, $paths);
     $factoryclass = isset($GLOBALS['DOCTRINE_PHPCR_FACTORY']) ? $GLOBALS['DOCTRINE_PHPCR_FACTORY'] : '\\Jackalope\\RepositoryFactoryJackrabbit';
     if ($factoryclass === '\\Jackalope\\RepositoryFactoryDoctrineDBAL') {
         $GLOBALS['jackalope.doctrine_dbal_connection'] = $this->connection;
     }
     /** @var $factory RepositoryFactoryInterface */
     $factory = new $factoryclass();
     $parameters = array_intersect_key($GLOBALS, $factory->getConfigurationKeys());
     // factory returns null if it gets unknown parameters
     $repository = $factory->getRepository($parameters);
     $this->assertNotNull($repository, 'There is an issue with your parameters: ' . var_export(array_keys($parameters), true));
     $workspace = isset($GLOBALS['DOCTRINE_PHPCR_WORKSPACE']) ? $GLOBALS['DOCTRINE_PHPCR_WORKSPACE'] : 'tests';
     $user = isset($GLOBALS['DOCTRINE_PHPCR_USER']) ? $GLOBALS['DOCTRINE_PHPCR_USER'] : '';
     $pass = isset($GLOBALS['DOCTRINE_PHPCR_PASS']) ? $GLOBALS['DOCTRINE_PHPCR_PASS'] : '';
     $credentials = new \PHPCR\SimpleCredentials($user, $pass);
     $session = $repository->login($credentials, $workspace);
     $this->sessions[] = $session;
     $config = new \Doctrine\ODM\PHPCR\Configuration();
     $config->setMetadataDriverImpl($metaDriver);
     $eventManager = new EventManager();
     $this->dm = DocumentManager::create($session, $config, $eventManager);
 }