UserFrosting API

MigrationDependencyAnalyser

MigrationDependencyAnalyser Class.

Helper class used to analyse migrations dependencies and return the migrations classes in the correct order for migration to be run up without dependency collisions.

Tags
author

Louis Charette

Table of Contents

$fulfillable Collection
$unfulfillable Collection
$installed Collection
$pending Collection
$analysed bool
__construct() Constructor. mixed
analyse() Analyse the dependencies. void
validateClassDependencies() Validate if a migration is fulfillable. bool
getFulfillable() Return the fulfillable list. Analyse the stack if not done already. array
getUnfulfillable() Return the fulfillable list. Analyse the stack if not done already. array
markAsFulfillable() Mark a dependency as fulfillable. Removes it from the pending list and add it to the fulfillable list. bool
markAsUnfulfillable() Mark a dependency as unfulfillable. Removes it from the pending list and add it to the unfulfillable list. bool
getMigrationDependencies() Returns the migration dependency list Also handles the old deprecated behaviour where dependencies where not in a static property. array
normalizeClasses() Normalize class so all class starts with '/'. string[]

Properties

Methods

__construct()

Constructor.

public __construct( [ $pending : array = [] ] [, $installed : array = [] ] ) : mixed
Parameters
$pending : array = []

The pending migrations

$installed : array = []

The installed migrations

Return values
mixed

validateClassDependencies()

Validate if a migration is fulfillable.

protected validateClassDependencies( $migrationName : string ) : bool

N.B.: The key element here is the recursion while validating the dependencies. This is very important as the order the migrations needs to be run is defined by this recursion. By waiting for the dependency to be marked as fulfillable to mark the parent as fulfillable, the parent class will be automatocally placed after it's dependencies in the fullfillable property.

Parameters
$migrationName : string

The migration classname

Return values
bool

True/False if the migration is fulfillable

getFulfillable()

Return the fulfillable list. Analyse the stack if not done already.

public getFulfillable( ) : array
Return values
array

getUnfulfillable()

Return the fulfillable list. Analyse the stack if not done already.

public getUnfulfillable( ) : array
Return values
array

markAsFulfillable()

Mark a dependency as fulfillable. Removes it from the pending list and add it to the fulfillable list.

protected markAsFulfillable( $migration : string ) : bool
Parameters
$migration : string

The migration classname

Return values
bool

True, it's fulfillable

markAsUnfulfillable()

Mark a dependency as unfulfillable. Removes it from the pending list and add it to the unfulfillable list.

protected markAsUnfulfillable( $migration : string , $dependency : string|array ) : bool
Parameters
$migration : string

The migration classname

$dependency : string|array

The problematic dependecy

Return values
bool

False, it's not fullfillable

getMigrationDependencies()

Returns the migration dependency list Also handles the old deprecated behaviour where dependencies where not in a static property.

protected getMigrationDependencies( $migration : string ) : array
Parameters
$migration : string

The migration class

Return values
array

The dependency list

normalizeClasses()

Normalize class so all class starts with '/'.

protected normalizeClasses( $classes : string[] ) : string[]
Parameters
$classes : string[]
Return values
string[]

Search results