예제 #1
0
 public function testSetMetadataDriverImpl()
 {
     $mockedMetadataDriverImpl = $this->getMockBuilder('Lib\\Common\\Persistence\\Mapping\\Driver\\MappingDriver')->disableOriginalConstructor()->getMock();
     $this->configuration->setMetadataDriverImpl($mockedMetadataDriverImpl);
     $metadataDriverImpl = $this->configuration->getMetadataDriverImpl();
     $this->assertInstanceOf('Lib\\Common\\Persistence\\Mapping\\Driver\\MappingDriver', $metadataDriverImpl);
 }
예제 #2
0
 /**
  *
  * @param array $connection
  * @param array $paths Array of Paths where Search Entities are found
  * @param \AppKernel $kernel
  */
 public function __construct(array $connection, array $paths = array(), \AppKernel $kernel)
 {
     $cacheProvider = 'Doctrine\\Common\\Cache\\ArrayCache';
     //Annotation metadata driver
     $config = new Configuration();
     $md = $config->newDefaultAnnotationDriver($paths);
     $config->setMetadataDriverImpl($md);
     $config->setMetadataCacheImpl(new $cacheProvider());
     $config->setEntitySerializer(new CallbackSerializer('toESDocument', 'fromESDocument'));
     $bundles = $kernel->getBundles();
     $entityNamespaces = array();
     foreach ($bundles as $bundle) {
         $nameSpace = $bundle->getNamespace();
         $name = $bundle->getName();
         $entityNamespaces[$name] = $nameSpace;
     }
     $config->setEntityNamespaces($entityNamespaces);
     $client = new \Elastica\Client(array('connections' => array($connection)));
     $this->searchManager = new SearchManager($config, new \Revinate\SearchBundle\Lib\Search\ElasticSearch\Client($client), new EventManager());
     $this->mappingManager = new MappingManager($this->searchManager, $kernel->getEnvironment());
 }