setVariantSupport() public static method

Enables or disables Variant support on a certain MetaModel table.
public static setVariantSupport ( string $strTableName, boolean $blnVariantSupport ) : void
$strTableName string The table name of the MetaModel.
$blnVariantSupport boolean Flag if the support shall be turned on or off.
return void
示例#1
0
 /**
  * Handle the update of a MetaModel and all attached data.
  *
  * @param PostPersistModelEvent $event The event.
  *
  * @return void
  */
 public function handleUpdate(PostPersistModelEvent $event)
 {
     if ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel') {
         return;
     }
     $old = $event->getOriginalModel();
     $new = $event->getModel();
     $oldTable = $old ? $old->getProperty('tableName') : null;
     $newTable = $new->getProperty('tableName');
     // Table name changed?
     if ($oldTable !== $newTable) {
         if ($oldTable && $this->getDatabase()->tableExists($oldTable, null, true)) {
             TableManipulation::renameTable($oldTable, $newTable);
             // TODO: notify attributes that the MetaModel has changed its table name.
         } else {
             TableManipulation::createTable($newTable);
         }
     }
     TableManipulation::setVariantSupport($newTable, $new->getProperty('varsupport'));
 }