src/CoreBundle/EventListener/DcGeneral/Table/Attribute/ColNameValidationListener.php
public function handle(EncodePropertyValueFromWidgetEvent $event)
    {
        if (!parent::wantToHandle($event) || ($event->getProperty() !== 'colname')) {
            return;
        }

        $oldColumnName = $event->getModel()->getProperty($event->getProperty());
        $columnName    = $event->getValue();
        $metaModel     = $this->getMetaModelByModelPid($event->getModel());

        if ((!$columnName) || $oldColumnName !== $columnName) {
            $this->tableManipulator->checkColumnDoesNotExist($metaModel->getTableName(), $columnName);

            $colNames = array_keys($metaModel->getAttributes());
            if (in_array($columnName, $colNames)) {
                throw new \RuntimeException(
                    sprintf(
                        $event->getEnvironment()->getTranslator()->translate('columnExists', 'ERR'),
                        $columnName,
                        $metaModel->getTableName()
                    )
                );
            }
        }
    }
public function handle(EncodePropertyValueFromWidgetEvent $event)
    {
        if (!parent::wantToHandle($event) || ($event->getProperty() !== 'colname')) {
            return;
        }

        $oldColumnName = $event->getModel()->getProperty($event->getProperty());
        $columnName    = $event->getValue();
        $metaModel     = $this->getMetaModelByModelPid($event->getModel());

        if ((!$columnName) || $oldColumnName !== $columnName) {
            $this->tableManipulator->checkColumnDoesNotExist($metaModel->getTableName(), $columnName);

            $colNames = array_keys($metaModel->getAttributes());
            if (in_array($columnName, $colNames)) {
                throw new \RuntimeException(
                    sprintf(
                        $event->getEnvironment()->getTranslator()->translate('columnExists', 'ERR'),
                        $columnName,
                        $metaModel->getTableName()
                    )
                );
            }
        }
    }
Validate the column name and ensure that the column does not exist already.

@param EncodePropertyValueFromWidgetEvent $event The event.

@return void

@throws \RuntimeException When the column name is illegal or duplicate.