public function validateVersionTable(EntityDefinition $entityMetadata)
    {
        $columnNames = [];
        $countPrimaryKeys = 0;
        $versionPrimaryKey = false;

        // get column names
        foreach ($entityMetadata['table']['columns'] as $column) {
            $columnNames[] = $column['name'];
        }

        if (! in_array('latest_version', $columnNames)) {
            throw new DomainException('@Versionable annotation defined in class ' . $entityMetadata['class'] . ' requires a $latestVersion column property.');
        }

        $columnNames = [];

        // get version column names
        foreach ($entityMetadata['versionTable']['columns'] as $column) {
            $columnNames[] = $column['name'];
            if (! empty($column['primary'])) {
                $countPrimaryKeys++;
            }
            if (! empty($column['primary']) && $column['name'] == 'version') {
                $versionPrimaryKey = true;
            }
        }

        if (! in_array('version', $columnNames) || ! $versionPrimaryKey) {
            throw new DomainException('@Versionable annotation defined in class ' . $entityMetadata['class'] . ' requires a $version property column, which is a primary key.');
        }
        if ($countPrimaryKeys > 2) {
            throw new DomainException('No more than 2 primary keys are allowed for version table in class ' . $entityMetadata['class'] . '.');
        }
    }
public function validateVersionTable(EntityDefinition $entityMetadata)
    {
        $columnNames = [];
        $countPrimaryKeys = 0;
        $versionPrimaryKey = false;

        // get column names
        foreach ($entityMetadata['table']['columns'] as $column) {
            $columnNames[] = $column['name'];
        }

        if (! in_array('latest_version', $columnNames)) {
            throw new DomainException('@Versionable annotation defined in class ' . $entityMetadata['class'] . ' requires a $latestVersion column property.');
        }

        $columnNames = [];

        // get version column names
        foreach ($entityMetadata['versionTable']['columns'] as $column) {
            $columnNames[] = $column['name'];
            if (! empty($column['primary'])) {
                $countPrimaryKeys++;
            }
            if (! empty($column['primary']) && $column['name'] == 'version') {
                $versionPrimaryKey = true;
            }
        }

        if (! in_array('version', $columnNames) || ! $versionPrimaryKey) {
            throw new DomainException('@Versionable annotation defined in class ' . $entityMetadata['class'] . ' requires a $version property column, which is a primary key.');
        }
        if ($countPrimaryKeys > 2) {
            throw new DomainException('No more than 2 primary keys are allowed for version table in class ' . $entityMetadata['class'] . '.');
        }
    }
public function validateVersionTable ( EntityDefinition $ entityMetadata ) { $ columnNames = [ ] ; $ countPrimaryKeys = 0 ; $ versionPrimaryKey = false ; // get column names foreach ( $ entityMetadata [ 'table' ] [ 'columns' ] as $ column ) { $ columnNames [ ] = $ column [ 'name' ] ; } if ( ! in_array ( 'latest_version' , $ columnNames ) ) { throw new DomainException ( '@Versionable annotation defined in class ' . $ entityMetadata [ 'class' ] . ' requires a $latestVersion column property.' ) ; } $ columnNames = [ ] ; // get version column names foreach ( $ entityMetadata [ 'versionTable' ] [ 'columns' ] as $ column ) { $ columnNames [ ] = $ column [ 'name' ] ; if ( ! empty ( $ column [ 'primary' ] ) ) { $ countPrimaryKeys ++ ; } if ( ! empty ( $ column [ 'primary' ] ) && $ column [ 'name' ] == 'version' ) { $ versionPrimaryKey = true ; } } if ( ! in_array ( 'version' , $ columnNames ) || ! $ versionPrimaryKey ) { throw new DomainException ( '@Versionable annotation defined in class ' . $ entityMetadata [ 'class' ] . ' requires a $version property column, which is a primary key.' ) ; } if ( $ countPrimaryKeys > 2 ) { throw new DomainException ( 'No more than 2 primary keys are allowed for version table in class ' . $ entityMetadata [ 'class' ] . '.' ) ; } }
Validate the version table.

@param \ProAI\Datamapper\Metadata\Definitions\Entity $entityMetadata
@return void
Validate the version table .