예제 #1
0
파일: DriverTest.php 프로젝트: vend/doxport
 public function testGetEntityNames()
 {
     $manager = $this->getMockEntityManager();
     $doctrine = $manager->getConfiguration()->getMetadataDriverImpl();
     $reader = $doctrine->getReader();
     $doctrine->expects($this->any())->method('getAllClassNames')->will($this->returnValue(['Doxport\\Metadata\\DriverTest']));
     $reader->expects($this->any())->method('getClassAnnotations')->will($this->returnValue([]));
     $instance = new Driver($manager);
     $entities = $instance->getEntityNames();
     $this->assertInternalType('array', $entities);
 }
예제 #2
0
 /**
  * @param Driver   $driver
  * @param callable $associationFilter
  * @return void
  */
 public function from(Driver $driver, callable $associationFilter)
 {
     $entities = $driver->getEntityNames();
     foreach ($entities as $entity) {
         $this->graph->createVertex($entity);
     }
     foreach ($entities as $entity) {
         foreach ($driver->getEntityMetadata($entity)->getClassMetadata()->getAssociationMappings() as $association) {
             if (!in_array($association['sourceEntity'], $entities) || !in_array($association['targetEntity'], $entities)) {
                 continue;
             }
             if (!$associationFilter($association)) {
                 continue;
             }
             $edge = $this->graph->getVertex($association['sourceEntity'])->createEdgeTo($this->graph->getVertex($association['targetEntity']));
             $edge->setLayoutAttribute('label', $association['fieldName']);
         }
     }
 }