SourceManifest

Reads and stores the Winter CMS source manifest information.

 class System\Classes\SourceManifest

The source manifest is a meta JSON file, stored on GitHub, that contains the hashsums of all module files across all builds of Winter CMS. This allows us to compare the Winter CMS installation against the expected file checksums and determine the installed build and whether it has been modified.

Since Winter CMS v1.1.1, a forks manifest is also used to determine at which point we forked a branch off to a new major release. This allows us to track concurrent histories - ie. the 1.0.x history vs. the 1.1.x history.

Properties

protected $builds : array

Array of builds, keyed by build number, with files for keys and hashes for values.

protected $forks : array

The version map where forks occurred.

protected $forksUrl : string

The URL to the forked version manifest

protected $source : string

The URL to the source manifest

Methods

public __construct ($source = null, $forks = null, boolean $autoload = true)

Constructor

Parameters
Property Description
$source
mixed
$forks
mixed
$autoload
boolean
Returns
mixed

public addBuild (int $build, System\Classes\FileManifest $manifest) : void

Adds a FileManifest instance as a build to this source manifest.

Changes between builds are calculated and stored with the build. Builds are stored in order of semantic versioning: ie. 1.1.1 > 1.1.0 > 1.0.468

Parameters
Property Description
$build
int

Build number.

$manifest
System\Classes\FileManifest

The file manifest to add as a build.

Returns
void

public compare (System\Classes\FileManifest $manifest, boolean $detailed = false) : array

Compares a file manifest with the source manifest.

This will determine the build of the Winter CMS installation.

This will return an array with the following information:

  • build: The build number we determined was most likely the build installed.
  • modified: Whether we detected any modifications between the installed build and the manifest.
  • confident: Whether we are at least 60% sure that this is the installed build. More modifications to to the code = less confidence.
  • changes: If $detailed is true, this will include the list of files modified, created and deleted.
Parameters
Property Description
$manifest
System\Classes\FileManifest

The file manifest to compare against the source.

$detailed
boolean

If true, the list of files modified, added and deleted will be included in the result.

Returns
array

public generate () : string

Generates the JSON data to be stored with the source manifest.

Returns
string

public getBuilds () : array

Gets all builds.

Returns
array

public getState (string | int $build) : array

Gets the filelist state at a selected build.

This method will list all expected files and hashsums at the specified build number. It does this by following the history, switching branches as necessary.

Parameters
Property Description
$build
string | int

Build version to get the filelist state for.

Returns
array

public loadForks () : static

Loads the forked version manifest file.

Returns
static

public loadSource () : static

Loads the manifest file.

Returns
static

public setForksSource (string $forks) : void

Sets the forked version manifest URL.

Parameters
Property Description
$forks
string
Returns
void

public setSource (string $source) : void

Sets the source manifest URL.

Parameters
Property Description
$source
string
Returns
void

protected determineParent (string $build) : array | null

Determine the parent of the provided build number

Parameters
Property Description
$build
string
Returns
array | null

protected getVersionInt (string $version) : integer

Converts a version string into an integer for comparison.

Parameters
Property Description
$version
string
Returns
integer

protected processChanges (System\Classes\FileManifest $manifest, FileManifest | string | int $previous = null) : array

Determines file changes between the specified build and the previous build.

Will return an array of added, modified and removed files.

Parameters
Property Description
$manifest
System\Classes\FileManifest

The current build's file manifest.

$previous
FileManifest | string | int

Either a previous manifest, or the previous build number as an int or string, used to determine changes with this build.

Returns
array
Copyright © 2024 Winter CMS