Skip to content

Commit

Permalink
Merge pull request #116 from humanmade/backport-114-to-v4-branch
Browse files Browse the repository at this point in the history
[Backport v4-branch] Fix About page for Composer v2
  • Loading branch information
roborourke authored Dec 11, 2020
2 parents 6a040cd + 86251db commit f0c1c7c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion inc/about/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ function get_module_version_data() : array {

$data = [];
foreach ( $modules as $module ) {
/** @var Module $module Altis module object. */
/**
* Altis module object.
*
* @var Module $module
*/
$package = sprintf( 'altis/%s', basename( $module->get_directory() ) );
$package_data = $composer_data[ $package ] ?? null;
$data[ $module->get_slug() ] = (object) [
Expand Down
6 changes: 6 additions & 0 deletions inc/composer/class-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,18 @@ public function init() {

/**
* {@inheritDoc}
*
* @param Composer $composer The composer class.
* @param IOInterface $io The composer disk interface.
*/
public function deactivate( Composer $composer, IOInterface $io ) {
}

/**
* {@inheritDoc}
*
* @param Composer $composer The composer class.
* @param IOInterface $io The composer disk interface.
*/
public function uninstall( Composer $composer, IOInterface $io ) {
}
Expand Down
5 changes: 5 additions & 0 deletions inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ function get_composer_data() : array {
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
$raw_data = json_decode( file_get_contents( $composer_file ) );

// Composer v2 file version support.
if ( isset( $raw_data->packages ) ) {
$raw_data = $raw_data->packages;
}

// Re-index by package slug.
$data = [];
foreach ( $raw_data as $package ) {
Expand Down

0 comments on commit f0c1c7c

Please sign in to comment.