Example #1
0
 function configurePathFinder(PathFinder $finder)
 {
     if ($this->pathfinderAlgorithm) {
         $finder->setAlgorithm($this->pathfinderAlgorithm);
     }
     if ($this->pathfinderMaxDepth) {
         $finder->setMaxDepth($this->pathfinderMaxDepth);
     }
 }
Example #2
0
 /**
  * Initialize the entity manager using the provided configuration.
  * Configuration options are detailed in the Configuration class.
  *
  * @param Configuration|array $configuration Various information about how the entity manager should behave.
  * @throws Exception
  */
 public function __construct($configuration = null)
 {
     if (is_null($configuration)) {
         $configuration = new Configuration();
     } elseif (is_array($configuration)) {
         $configuration = new Configuration($configuration);
     } elseif (!$configuration instanceof Configuration) {
         throw new Exception('Provided argument must be a Configuration object or an array.');
     }
     $this->proxyFactory = $configuration->getProxyFactory();
     $this->client = $configuration->getClient();
     $this->metaRepository = $configuration->getMetaRepository();
     $this->dateGenerator = function () {
         $currentDate = new \DateTime();
         return $currentDate->format('Y-m-d H:i:s');
     };
     $this->pathFinder = new PathFinder\PathFinder();
     $this->pathFinder->setEntityManager($this);
     $configuration->configurePathFinder($this->pathFinder);
 }
Example #3
0
 function testPathFinderMaxDepthAndAlgorithm()
 {
     $configuration = new Configuration(array('pathfinder_maxdepth' => 5, 'pathfinder_algorithm' => PathFinderImpl::AlgoAllSimple));
     $finder = new PathFinder();
     $configuration->configurePathFinder($finder);
     $expect = new PathFinder();
     $expect->setMaxDepth(5);
     $expect->setAlgorithm(PathFinderImpl::AlgoAllSimple);
     $this->assertEquals($expect, $finder);
 }