Skip to content

Commit

Permalink
Add the jetpack_package_versions filter and the Package_Version_Track…
Browse files Browse the repository at this point in the history
…er class.

Add the new Package_Version_Tracker class, which will obtain the package versions using
the package versions using the jetpack_package_versions filter.
  • Loading branch information
kbrown9 committed Jul 14, 2021
1 parent 0502036 commit d3d1932
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 0 deletions.
3 changes: 3 additions & 0 deletions projects/packages/backup/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@

// Register REST routes.
add_action( 'rest_api_init', array( 'Automattic\\Jetpack\\Backup\\REST_Controller', 'register_rest_routes' ) );

// Set up package version hook.
add_filter( 'jetpack_package_versions', 'Automattic\\Jetpack\\Backup\\Package_Version::send_package_version_to_tracker' );
3 changes: 3 additions & 0 deletions projects/packages/backup/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
"extra": {
"autotagger": true,
"mirror-repo": "Automattic/jetpack-backup",
"version-constants": {
"::PACKAGE_VERSION": "src/class-package-version.php"
},
"changelogger": {
"link-template": "https://github.com/Automattic/jetpack-backup/compare/v${old}...v${new}"
},
Expand Down
30 changes: 30 additions & 0 deletions projects/packages/backup/src/class-package-version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* The Package_Version class.
*
* @package automattic/jetpack-backup
*/

namespace Automattic\Jetpack\Backup;

/**
* The Package_Version class.
*/
class Package_Version {

const PACKAGE_VERSION = '1.1.1-alpha';

const PACKAGE_SLUG = 'backup';

/**
* Adds the package slug and version to the package version tracker's data.
*
* @param array $package_versions The package version array.
*
* @return array The packge version array.
*/
public static function send_package_version_to_tracker( $package_versions ) {
$package_versions[ self::PACKAGE_SLUG ] = self::PACKAGE_VERSION;
return $package_versions;
}
}
3 changes: 3 additions & 0 deletions projects/packages/connection/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
"extra": {
"autotagger": true,
"mirror-repo": "Automattic/jetpack-connection",
"version-constants": {
"::PACKAGE_VERSION": "src/class-package-version.php"
},
"changelogger": {
"link-template": "https://github.com/Automattic/jetpack-connection/compare/v${old}...v${new}"
},
Expand Down
5 changes: 5 additions & 0 deletions projects/packages/connection/src/class-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ public static function configure() {
add_filter( 'jetpack_heartbeat_stats_array', array( $manager, 'add_stats_to_heartbeat' ) );

Webhooks::init( $manager );

add_filter( 'plugins_loaded', __NAMESPACE__ . '\Package_Version_Tracker::get_package_versions' );

// Set up package version hook.
add_filter( 'jetpack_package_versions', __NAMESPACE__ . '\Package_Version::send_package_version_to_tracker' );
}

/**
Expand Down
30 changes: 30 additions & 0 deletions projects/packages/connection/src/class-package-version-tracker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* The Package_Version_Tracker class.
*
* @package automattic/jetpack-connection
*/

namespace Automattic\Jetpack\Connection;

/**
* The Package_Version_Tracker class.
*/
class Package_Version_Tracker {

/**
* Uses the jetpack_package_versions filter to obtain the package versions from packages that need
* version tracking.
*/
public static function get_package_versions() {
/**
* Obtains the package versions.
*
* @since x.x.x
*
* @param array An associative array containing the package versions with the package slugs as the keys.
*/
$package_versions = apply_filters( 'jetpack_package_versions', array() );

}
}
30 changes: 30 additions & 0 deletions projects/packages/connection/src/class-package-version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* The Package_Version class.
*
* @package automattic/jetpack-connection
*/

namespace Automattic\Jetpack\Connection;

/**
* The Package_Version class.
*/
class Package_Version {

const PACKAGE_VERSION = '1.30.1-alpha';

const PACKAGE_SLUG = 'connection';

/**
* Adds the package slug and version to the package version tracker's data.
*
* @param array $package_versions The package version array.
*
* @return array The packge version array.
*/
public static function send_package_version_to_tracker( $package_versions ) {
$package_versions[ self::PACKAGE_SLUG ] = self::PACKAGE_VERSION;
return $package_versions;
}
}
3 changes: 3 additions & 0 deletions projects/packages/sync/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
"extra": {
"autotagger": true,
"mirror-repo": "Automattic/jetpack-sync",
"version-constants": {
"::PACKAGE_VERSION": "src/class-package-version.php"
},
"changelogger": {
"link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}"
},
Expand Down
3 changes: 3 additions & 0 deletions projects/packages/sync/src/class-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public static function configure() {

// Initialize Identity Crisis.
add_action( 'plugins_loaded', array( 'Automattic\\Jetpack\\Identity_Crisis', 'init' ) );

// Set up package version hook.
add_filter( 'jetpack_package_versions', __NAMESPACE__ . '\Package_Version::send_package_version_to_tracker' );
}

/**
Expand Down
30 changes: 30 additions & 0 deletions projects/packages/sync/src/class-package-version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* The Package_Version class.
*
* @package automattic/jetpack-sync
*/

namespace Automattic\Jetpack\Sync;

/**
* The Package_Version class.
*/
class Package_Version {

const PACKAGE_VERSION = '1.24.0-alpha';

const PACKAGE_SLUG = 'sync';

/**
* Adds the package slug and version to the package version tracker's data.
*
* @param array $package_versions The package version array.
*
* @return array The packge version array.
*/
public static function send_package_version_to_tracker( $package_versions ) {
$package_versions[ self::PACKAGE_SLUG ] = self::PACKAGE_VERSION;
return $package_versions;
}
}

0 comments on commit d3d1932

Please sign in to comment.