Xpressengine\DynamicField\AbstractType::dropField PHP Method

dropField() private method

Dynamic Field 삭제 시 alter table 로 처리
private dropField ( ) : void
return void
    private function dropField()
    {
        $self = $this;
        $schema = $this->handler->connection()->getSchemaBuilder();
        $tableName = $this->handler->getConfigHandler()->getTableName($this->config);
        if ($schema->hasTable($tableName) === false) {
            throw new Exceptions\NotExistRevisionTableException();
        }
        foreach ($this->getColumns() as $column) {
            if ($schema->hasColumn($tableName, $column->name) === true) {
                throw new Exceptions\AlreadyExistColumnException();
            }
        }
        $this->handler->connection()->getSchemaBuilder()->table($tableName, function (Blueprint $table) use($self) {
            /**
             * @var ColumnEntity $column
             */
            foreach ($self->getColumns() as $column) {
                $column->drop($table, $self->config->get('id') . '_');
            }
        });
        if ($this->config->get('revision') == true) {
            $tableName = $this->handler->getConfigHandler()->getRevisionTableName($this->config);
            if ($schema->hasTable($tableName) === false) {
                throw new Exceptions\NotExistRevisionTableException();
            }
            foreach ($self->getColumns() as $column) {
                if ($schema->hasColumn($tableName, $column->name) === true) {
                    throw new Exceptions\AlreadyExistColumnException();
                }
            }
            $this->handler->connection()->getSchemaBuilder()->table($tableName, function (Blueprint $table) use($self) {
                /**
                 * @var ColumnEntity $column
                 */
                foreach ($self->getColumns() as $column) {
                    $column->drop($table);
                }
            });
        }
    }