PHP Class VersionPress\Utils\ReferenceUtils

显示文件 Open project: versionpress/versionpress Class Usage Examples

Public Methods

Method Description
getMatchingPaths ( array | object $value, string $pathInStructure ) : array Returns list of all paths in hierarchic structure (nested arrays, objects) matching given pattern.
getMnReferenceDetails ( DbSchemaInfo $dbSchema, $entityName, $reference ) : array Returns complex info about the M:N reference. The source is always the given entity, target is the second one.
getValueReferenceDetails ( string $reference ) : array Returns parsed info about the value reference.
valueMatchesWildcard ( $valueWithWildcards, $value )

Private Methods

Method Description
getMatchingPathsFromSubtree ( $value, $pathParts )
getSourceColumn ( DbSchemaInfo $dbSchema, $sourceEntity, $targetEntity, $junctionTable ) : string Returns name of column referencing synchronized entity in the junction table.

Method Details

getMatchingPaths() public static method

The pattern comes from a schema file. For example line some_option[/\d+/]["key"] contains pattern [/\d+/]["key"]. It can contain regular expressions to match multiple / dynamic keys. Examples: For $value = [0 => [key => value], 1 => [key => value]] And $pathInStructure = [0]["key"] Returns [[0, key]] For the same $value nad $pathInStructure = [/\d+/]["key"] Returns [[0, key], [1, key]]
public static getMatchingPaths ( array | object $value, string $pathInStructure ) : array
$value array | object
$pathInStructure string
return array

getMnReferenceDetails() public static method

Returns complex info about the M:N reference. The source is always the given entity, target is the second one.
public static getMnReferenceDetails ( DbSchemaInfo $dbSchema, $entityName, $reference ) : array
$dbSchema VersionPress\Database\DbSchemaInfo
$entityName
$reference
return array The details has keys 'junction-table', 'source-entity', 'source-column', 'target-entity' and 'target-column'.

getValueReferenceDetails() public static method

Returns parsed info about the value reference.
public static getValueReferenceDetails ( string $reference ) : array
$reference string
return array The details has keys 'source-column', 'source-value', 'value-column'

valueMatchesWildcard() public static method

public static valueMatchesWildcard ( $valueWithWildcards, $value )