1. Home
  2. Knowledge Base
  3. Custom Development
  4. Version Repository – retrieve_single
  1. Home
  2. Knowledge Base
  3. Version Repository
  4. Version Repository – retrieve_single

Version Repository – retrieve_single

Please note: Functionality described on this page requires Download Monitor version 4.0 or above.

Versions in Download Monitor can be fetched via the Version Repository. Retrieve_single is a method of Download Monitor’s version repository service. The method returns a single DLM_Download_Version object with given ID. Retrieve_single throws an Exception if no version with given ID is found.

Signature

[wpkb_code lang=”php”]public function retrieve_single( $id );[/wpkb_code]

Parameters

ParameterTypeDefaultDescription
$idintn/aID of the version that needs to be fetched.

Examples

Retrieve Version with ID 91

This snippet retrieves version with ID 91. Notice that the retrieve_single call is wrapped in a try-catch block. This is because the retrieve_single method throws an exception if no Version with given ID is found.

[wpkb_code lang=”php”]
try {
// retrieve version with ID 91
/** @var DLM_Download_Version $version */
$version = download_monitor()->service( ‘version_repository’ )->retrieve_single( 91 );
} catch ( Exception $exception ) {
// version with ID 91 not found
}
[/wpkb_code]

Was this article helpful?

Related Articles