Skip to content

Commit

Permalink
Move the logic to get community packages to its own method. Need to u…
Browse files Browse the repository at this point in the history
…se it in the installer.
  • Loading branch information
danielbachhuber committed Jul 22, 2013
1 parent 9ec034d commit dad6b52
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion php/commands/package.php
Expand Up @@ -48,7 +48,7 @@ public function browse( $args, $assoc_args ) {
$wp_cli_repo = array_shift( $repos );

$packages = array();
foreach( $wp_cli_repo->getPackages() as $package ) {
foreach( $this->get_community_packages() as $package ) {

$package_output = new stdClass;
$package_output->name = $package->getName();
Expand Down Expand Up @@ -177,6 +177,22 @@ private function get_composer() {
return $this->composer;
}

/**
* Get all of the community packages
*/
private function get_community_packages() {

$composer = $this->get_composer();
$repos = $composer->getRepositoryManager()->getRepositories();

// @todo Is there a better way of getting the WP-CLI repo?
// ... there doesn't seem to be a method for getting any unique ID
// and right now we're assuming WP-CLI is the first repo listed
$wp_cli_repo = array_shift( $repos );

return $wp_cli_repo->getPackages();
}

/**
* Get the installed community packages.
*/
Expand Down

0 comments on commit dad6b52

Please sign in to comment.