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
Property | Type | Description |
---|---|---|
$source | mixed |
mixed
|
$forks | mixed |
mixed
|
$autoload | boolean |
boolean
|
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
Property | Type | Description |
---|---|---|
$build | int |
int
Build number. |
$manifest | System\Classes\FileManifest |
System\Classes\FileManifest
The file manifest to add as a build. |
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.
Property | Type | Description |
---|---|---|
$manifest | System\Classes\FileManifest |
System\Classes\FileManifest
The file manifest to compare against the source. |
$detailed | boolean |
boolean
If true, the list of files modified, added and deleted will be included in the result. |
public generate () : string
Generates the JSON data to be stored with the source manifest.
public getBuilds () : array
Gets all builds.
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.
Property | Type | Description |
---|---|---|
$build | string | int |
string | int
Build version to get the filelist state for. |
public loadForks () : static
Loads the forked version manifest file.
public loadSource () : static
Loads the manifest file.
public setForksSource (string $forks) : void
Sets the forked version manifest URL.
Property | Type | Description |
---|---|---|
$forks | string |
string
|
public setSource (string $source) : void
Sets the source manifest URL.
Property | Type | Description |
---|---|---|
$source | string |
string
|
protected determineParent (string $build) : array | null
Determine the parent of the provided build number
Property | Type | Description |
---|---|---|
$build | string |
string
|
protected getVersionInt (string $version) : integer
Converts a version string into an integer for comparison.
Property | Type | Description |
---|---|---|
$version | string |
string
|
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.
Property | Type | Description |
---|---|---|
$manifest | System\Classes\FileManifest |
System\Classes\FileManifest
The current build's file manifest. |
$previous | FileManifest | string | int |
FileManifest | string | int
Either a previous manifest, or the previous build number as an int or string, used to determine changes with this build. |