Example #1
0
 /**
  * Expand modules dependencies from chain
  *
  * @param string $vertex
  * @param array $path nesting path
  * @return void
  */
 protected function expandDependencies($vertex, $path = [])
 {
     if (!$this->dependencies[$vertex]) {
         return;
     }
     $path[] = $vertex;
     foreach ($this->dependencies[$vertex] as $dependency) {
         if (!isset($this->dependencies[$dependency])) {
             // dependency vertex is not described in basic definition
             continue;
         }
         $relations = $this->graph->getRelations();
         if (isset($relations[$vertex][$dependency])) {
             continue;
         }
         $this->graph->addRelation($vertex, $dependency);
         $searchResult = array_search($dependency, $path);
         if (false !== $searchResult) {
             $this->buildCircular(array_slice($path, $searchResult));
             break;
         } else {
             $this->expandDependencies($dependency, $path);
         }
     }
 }