VersionPress\Database\EntityInfo::__construct PHP Method

__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' ) ))
    public function __construct($entitySchema)
    {
        list($key) = array_keys($entitySchema);
        $this->entityName = $key;
        $schemaInfo = $entitySchema[$key];
        if (isset($schemaInfo['table'])) {
            $this->tableName = $schemaInfo['table'];
        } else {
            $this->tableName = $this->entityName;
        }
        // The schema defines either 'id' or 'vpid', see schema-readme.md. This has this meaning:
        if (isset($schemaInfo['id'])) {
            $this->idColumnName = $schemaInfo['id'];
            $this->vpidColumnName = 'vp_id';
            // convention
            $this->usesGeneratedVpids = true;
            $this->hasNaturalVpid = false;
        } else {
            $this->idColumnName = $schemaInfo['vpid'];
            $this->vpidColumnName = $schemaInfo['vpid'];
            $this->usesGeneratedVpids = false;
            $this->hasNaturalVpid = true;
        }
        if (isset($schemaInfo['parent-reference'])) {
            $this->parentReference = $schemaInfo['parent-reference'];
        }
        if (isset($schemaInfo['references'])) {
            $this->references = $schemaInfo['references'];
            $this->hasReferences = true;
        }
        if (isset($schemaInfo['mn-references'])) {
            foreach ($schemaInfo['mn-references'] as $reference => $targetEntity) {
                if (Strings::startsWith($reference, '~')) {
                    $reference = Strings::substring($reference, 1);
                    $this->virtualReferences[$reference] = true;
                }
                $this->mnReferences[$reference] = $targetEntity;
            }
            $this->hasReferences = true;
        }
        if (isset($schemaInfo['value-references'])) {
            foreach ($schemaInfo['value-references'] as $key => $references) {
                list($keyCol, $valueCol) = explode('@', $key);
                foreach ($references as $reference => $targetEntity) {
                    $key = $keyCol . '=' . $reference . '@' . $valueCol;
                    $this->valueReferences[$key] = $targetEntity;
                }
            }
            $this->hasReferences = true;
        }
        if (isset($schemaInfo['frequently-written'])) {
            $this->frequentlyWritten = $schemaInfo['frequently-written'];
        }
        if (isset($schemaInfo['ignored-entities'])) {
            $this->ignoredEntities = $schemaInfo['ignored-entities'];
        }
        if (isset($schemaInfo['ignored-columns'])) {
            foreach ($schemaInfo['ignored-columns'] as $column) {
                if (is_string($column)) {
                    $this->ignoredColumns[$column] = function () {
                    };
                    // if column does not have any compute function we create 'NOOP' function
                } else {
                    $this->ignoredColumns[array_keys($column)[0]] = substr(array_values($column)[0], 1);
                }
            }
        }
        if (isset($schemaInfo['clean-cache'])) {
            $this->cleanCache = $schemaInfo['clean-cache'];
        }
    }