hasNode() public method

Checks the existence of a node in the graph.
public hasNode ( string $hash ) : boolean
$hash string
return boolean
Beispiel #1
0
 /**
  * @param EntityManagerInterface $em
  * @param ClassMetadata[]        $classes
  *
  * @return ClassMetadata[]
  */
 private function getCommitOrder(EntityManagerInterface $em, array $classes)
 {
     $sorter = new TopologicalSorter();
     foreach ($classes as $class) {
         if (!$sorter->hasNode($class->name)) {
             $sorter->addNode($class->name, $class);
         }
         // $class before its parents
         foreach ($class->parentClasses as $parentClass) {
             $parentClass = $em->getClassMetadata($parentClass);
             $parentClassName = $parentClass->getName();
             if (!$sorter->hasNode($parentClassName)) {
                 $sorter->addNode($parentClassName, $parentClass);
             }
             $sorter->addDependency($class->name, $parentClassName);
         }
         foreach ($class->associationMappings as $assoc) {
             if ($assoc['isOwningSide']) {
                 /* @var $targetClass ClassMetadata */
                 $targetClass = $em->getClassMetadata($assoc['targetEntity']);
                 $targetClassName = $targetClass->getName();
                 if (!$sorter->hasNode($targetClassName)) {
                     $sorter->addNode($targetClassName, $targetClass);
                 }
                 // add dependency ($targetClass before $class)
                 $sorter->addDependency($targetClassName, $class->name);
                 // parents of $targetClass before $class, too
                 foreach ($targetClass->parentClasses as $parentClass) {
                     $parentClass = $em->getClassMetadata($parentClass);
                     $parentClassName = $parentClass->getName();
                     if (!$sorter->hasNode($parentClassName)) {
                         $sorter->addNode($parentClassName, $parentClass);
                     }
                     $sorter->addDependency($parentClassName, $class->name);
                 }
             }
         }
     }
     return array_reverse($sorter->sort());
 }