소스 검색

RepositoryManager::prependRepository()

This method is useful for dynamically adding repositories with
higher priority than Packagist, e.g. from a Composer plugin.
Franz Liedke 9 년 전
부모
커밋
ea30392105
1개의 변경된 파일12개의 추가작업 그리고 0개의 파일을 삭제
  1. 12 0
      src/Composer/Repository/RepositoryManager.php

+ 12 - 0
src/Composer/Repository/RepositoryManager.php

@@ -89,6 +89,18 @@ class RepositoryManager
         $this->repositories[] = $repository;
         $this->repositories[] = $repository;
     }
     }
 
 
+    /**
+     * Adds a repository to the beginning of the chain
+     *
+     * This is useful when injecting additional repositories that should trump Packagist, e.g. from a plugin.
+     *
+     * @param RepositoryInterface $repository repository instance
+     */
+    public function prependRepository(RepositoryInterface $repository)
+    {
+        array_unshift($this->repositories, $repository);
+    }
+
     /**
     /**
      * Returns a new repository for a specific installation type.
      * Returns a new repository for a specific installation type.
      *
      *