Craft\NeoService::deleteBlockType PHP Method

deleteBlockType() public method

Deletes a block type from the database.
public deleteBlockType ( Neo_BlockTypeModel $blockType ) : boolean
$blockType Neo_BlockTypeModel
return boolean
    public function deleteBlockType(Neo_BlockTypeModel $blockType)
    {
        $transaction = $this->beginTransaction();
        try {
            // First delete the blocks of this type
            $blockIds = craft()->db->createCommand()->select('id')->from('neoblocks')->where(['typeId' => $blockType->id])->queryColumn();
            $this->deleteBlockById($blockIds);
            // Delete the field layout
            craft()->fields->deleteLayoutById($blockType->fieldLayoutId);
            // Finally delete the actual block type
            $affectedRows = craft()->db->createCommand()->delete('neoblocktypes', ['id' => $blockType->id]);
            $this->commitTransaction($transaction);
            return (bool) $affectedRows;
        } catch (\Exception $e) {
            $this->rollbackTransaction($transaction);
            throw $e;
        }
    }