PHP Class VersionPress\Database\EntityInfo

Show file Open project: versionpress/versionpress Class Usage Examples

Public Properties

Property Type Description
$cleanCache
$entityName string Name of the entity, e.g. 'post' or 'comment'.
$hasNaturalVpid boolean If the entity has natural VPID, the $idColumnName and $vpidColumnName will point to the same column. The opposite is $usesGeneratedVpids.
$hasReferences boolean True if entity has references. Basically returns count($references) > 0.
$idColumnName string Name of a column that uniquely identifies the entity within a db table. This is most commonly an auto-increment primary key but not always - e.g., options use the 'option_name' which is not a primary key in that table but is a local id as far as VersionPress is concerned.
$mnReferences array The key is composed from table name and column in the junction table. This kind of relationship has to be described in both entities. Post: array( 'term_taxonomy.term_taxonomy_id' => 'term_taxonomy', ) Term taxonomy: array( 'term_taxonomy.object_id' => 'post', )
$parentReference string If entity is child entity (meta, term_taxonomy etc.), this contains name of reference to its parent.
$references array array( 'post_author' => 'user', 'post_parent' => 'post' ) If the entity doesn't have references, returns empty array.
$storageClass
$tableName string Name of DB table where the entity is stored. By default it's {@see entityName}.
$usesGeneratedVpids boolean The opposite is $hasNaturalVpid.
$valueReferences array The key consists of name of column, where reference source is stored with its value and column, where is name of referenced entities. array( 'meta_key=_thumbnail_id@meta_value' => 'post', 'meta_key=menu_object_item_id@meta_value' => 'post', )
$vpidColumnName string Name of a column that stores a globally unique VersionPress ID (VPID). For entities that use auto-increment $idColumnName this will be 'vp_id' and VersionPress will generate and maintain VPIDs for such entities. The opposite example is the options entity - the 'option_name' column already identifies the option globally and uniquely so it can be this VPID column name directly.

Public Methods

Method Description
__construct ( array $entitySchema ) Does the parsing and sets all properties
getIgnoredColumns ( )
getReferencedEntities ( ) : array Returns list of referenced entities.
getRulesAndIntervalsForFrequentlyWrittenEntities ( )
getRulesForIgnoredEntities ( )
isFrequentlyWrittenEntity ( $entity )
isIgnoredEntity ( $entity )
isVirtualReference ( $reference )

Method Details

__construct() public method

Does the parsing and sets all properties
public __construct ( array $entitySchema )
$entitySchema array Example: array('post' => array( 'table' => 'posts', 'id' => 'ID', 'references' => array ( 'post_author' => 'user' ) ))

getIgnoredColumns() public method

public getIgnoredColumns ( )

getReferencedEntities() public method

Returns list of referenced entities.
public getReferencedEntities ( ) : array
return array

getRulesAndIntervalsForFrequentlyWrittenEntities() public method

getRulesForIgnoredEntities() public method

isFrequentlyWrittenEntity() public method

public isFrequentlyWrittenEntity ( $entity )

isIgnoredEntity() public method

public isIgnoredEntity ( $entity )

isVirtualReference() public method

public isVirtualReference ( $reference )

Property Details

$cleanCache public property

public $cleanCache

$entityName public property

Name of the entity, e.g. 'post' or 'comment'.
public string $entityName
return string

$hasNaturalVpid public property

If the entity has natural VPID, the $idColumnName and $vpidColumnName will point to the same column. The opposite is $usesGeneratedVpids.
public bool $hasNaturalVpid
return boolean

$hasReferences public property

True if entity has references. Basically returns count($references) > 0.
public bool $hasReferences
return boolean

$idColumnName public property

Name of a column that uniquely identifies the entity within a db table. This is most commonly an auto-increment primary key but not always - e.g., options use the 'option_name' which is not a primary key in that table but is a local id as far as VersionPress is concerned.
public string $idColumnName
return string

$mnReferences public property

The key is composed from table name and column in the junction table. This kind of relationship has to be described in both entities. Post: array( 'term_taxonomy.term_taxonomy_id' => 'term_taxonomy', ) Term taxonomy: array( 'term_taxonomy.object_id' => 'post', )
public array $mnReferences
return array

$parentReference public property

If entity is child entity (meta, term_taxonomy etc.), this contains name of reference to its parent.
public string $parentReference
return string

$references public property

array( 'post_author' => 'user', 'post_parent' => 'post' ) If the entity doesn't have references, returns empty array.
public array $references
return array

$storageClass public property

public $storageClass

$tableName public property

Name of DB table where the entity is stored. By default it's {@see entityName}.
public string $tableName
return string

$usesGeneratedVpids public property

The opposite is $hasNaturalVpid.
public bool $usesGeneratedVpids
return boolean

$valueReferences public property

The key consists of name of column, where reference source is stored with its value and column, where is name of referenced entities. array( 'meta_key=_thumbnail_id@meta_value' => 'post', 'meta_key=menu_object_item_id@meta_value' => 'post', )
public array $valueReferences
return array

$vpidColumnName public property

Name of a column that stores a globally unique VersionPress ID (VPID). For entities that use auto-increment $idColumnName this will be 'vp_id' and VersionPress will generate and maintain VPIDs for such entities. The opposite example is the options entity - the 'option_name' column already identifies the option globally and uniquely so it can be this VPID column name directly.
public string $vpidColumnName
return string