src/Helper/TableManipulator.php
public function setVariantSupport($strTableName, $blnVariantSupport)
    {
        if ($blnVariantSupport) {
            if ($this->connection->getSchemaManager()->tablesExist([$strTableName])
                && (!$this->fieldExists($strTableName, 'varbase'))) {
                $this->createColumn($strTableName, 'varbase', 'char(1) NOT NULL default \'\'', true);
                $this->createColumn($strTableName, 'vargroup', 'int(11) NOT NULL default 0', true);

                // If there is pre-existing data in the table, we need to provide a separate 'vargroup' value to all of
                // them, we can do this safely by setting all vargroups to the id of the base item.
                $this->connection->query(sprintf('UPDATE %s SET vargroup=id, varbase=1', $strTableName));
            }
        } else {
            if ($this->connection->getSchemaManager()->tablesExist([$strTableName])
                && $this->fieldExists($strTableName, 'varbase')
            ) {
                $this->dropColumn($strTableName, 'varbase', true);
                $this->dropColumn($strTableName, 'vargroup', true);
            }
        }
    }
public function setVariantSupport($strTableName, $blnVariantSupport)
    {
        if ($blnVariantSupport) {
            if ($this->connection->getSchemaManager()->tablesExist([$strTableName])
                && (!$this->fieldExists($strTableName, 'varbase'))) {
                $this->createColumn($strTableName, 'varbase', 'char(1) NOT NULL default \'\'', true);
                $this->createColumn($strTableName, 'vargroup', 'int(11) NOT NULL default 0', true);

                // If there is pre-existing data in the table, we need to provide a separate 'vargroup' value to all of
                // them, we can do this safely by setting all vargroups to the id of the base item.
                $this->connection->query(sprintf('UPDATE %s SET vargroup=id, varbase=1', $strTableName));
            }
        } else {
            if ($this->connection->getSchemaManager()->tablesExist([$strTableName])
                && $this->fieldExists($strTableName, 'varbase')
            ) {
                $this->dropColumn($strTableName, 'varbase', true);
                $this->dropColumn($strTableName, 'vargroup', true);
            }
        }
    }
public function setVariantSupport ( $ strTableName , $ blnVariantSupport ) { if ( $ blnVariantSupport ) { if ( $ this -> connection -> getSchemaManager ( ) -> tablesExist ( [ $ strTableName ] ) && ( ! $ this -> fieldExists ( $ strTableName , 'varbase' ) ) ) { $ this -> createColumn ( $ strTableName , 'varbase' , 'char(1) NOT NULL default \'\'' , true ) ; $ this -> createColumn ( $ strTableName , 'vargroup' , 'int(11) NOT NULL default 0' , true ) ; // If there is pre-existing data in the table, we need to provide a separate 'vargroup' value to all of // them, we can do this safely by setting all vargroups to the id of the base item. $ this -> connection -> query ( sprintf ( 'UPDATE %s SET vargroup=id, varbase=1' , $ strTableName ) ) ; } } else { if ( $ this -> connection -> getSchemaManager ( ) -> tablesExist ( [ $ strTableName ] ) && $ this -> fieldExists ( $ strTableName , 'varbase' ) ) { $ this -> dropColumn ( $ strTableName , 'varbase' , true ) ; $ this -> dropColumn ( $ strTableName , 'vargroup' , true ) ; } } }
Enables or disables Variant support on a certain MetaModel table.

@param string $strTableName      The table name of the MetaModel.

@param bool   $blnVariantSupport Flag if the support shall be turned on or off.

@return void
Enables or disables Variant support on a certain MetaModel table .