Deletes a block type.

@param SuperTableBlockTypeModel $blockType The block type.
@return bool Whether the block type was deleted successfully.
778895
public function deleteBlockType(SuperTableBlockTypeModel $blockType): bool
    {
        Craft::$app->getProjectConfig()->remove(self::CONFIG_BLOCKTYPE_KEY . '.' . $blockType->uid);

        return true;
    }
1119379
protected function getDisplayLogicPrototypes(BlockInterface $block)
    {
        $collection = new PrototypeCollection([
            new OrXPrototype(),
            new AndXPrototype(),
            new EventPrototype('click_event', 'Click Event', 'event.type.click'),
            new TextPrototype('dom_node_id', 'DOM Node Id', 'node.id')
        ]);

        $owner = $block->getOwner();
        if ($owner) {
            // Avoid trying to add display logic for blocks when the current block has no owner (e.g. shared blocks)
            $blockChoices = [];
            foreach ($owner->getBlocks() as $member) {
                try {
                    $properties = $member->getProperties();

                    if ($member instanceof ChoiceFieldBlock) {
                        if (empty($member->getName())) {
                            continue;
                        }
                        if (!isset($properties['options'])) {
                            continue;
                        }
                        $choices = [];
                        foreach ($properties['options'] as $option) {
                            if (empty($option['key'])) {
                                continue;
                            }
                            $choices[] = new Choice($option['key'], $option['value']);
                        }
                        $collection->add(new SelectPrototype($member->getName(), $properties['label'], $member->getName(), $choices));
                    } elseif ($member instanceof NumberFieldBlock || $member instanceof RangeFieldBlock) {
                        if (empty($member->getName())) {
                            continue;
                        }

                        $collection->add(new NumberPrototype($member->getName(), $properties['label'], $member->getName()));
                    }

                    if (!empty($member->getName())) {
                        $blockChoices[] = new Choice($member->getName(), $member->getName());
                    }
                } catch (\Exception $e) {
                    // Avoid throwing exceptions here for now, since e.g. duplicate namesthis will cause all blocks to be uneditable.
                }
            }

            $collection->add(new SelectPrototype('block_name', 'Block Name', 'block.name', $blockChoices));
        }

        return $collection->all();
    }
1074650
public function getBlockTypesByFieldId(int $fieldId): array
    {
        if (!empty($this->_fetchedAllBlockTypesForFieldId[$fieldId])) {
            return $this->_blockTypesByFieldId[$fieldId];
        }

        $this->_blockTypesByFieldId[$fieldId] = [];

        $results = $this->_createBlockTypeQuery()
            ->where(['fieldId' => $fieldId])
            ->all();

        foreach ($results as $result) {
            $blockType = new SuperTableBlockTypeModel($result);
            $this->_blockTypesById[$blockType->id] = $blockType;
            $this->_blockTypesByFieldId[$fieldId][] = $blockType;
        }

        $this->_fetchedAllBlockTypesForFieldId[$fieldId] = true;

        return $this->_blockTypesByFieldId[$fieldId];
    }
1336673
private function resetCraftMatrixFieldBlockTypesCache(Model $record)
    {
        $obj = $record;
        $refObject = new \ReflectionObject($obj);
        if ($refObject->hasProperty('_blockTypes')) {
            $refProperty1 = $refObject->getProperty('_blockTypes');
            $refProperty1->setAccessible(true);
            $refProperty1->setValue($obj, null);
        }
    }
645056
public function deleteOldType(Type $fromType)
    {
        $this->contentTypeGateway->delete($fromType->id, $fromType->status, $fromType->fieldDefinitions);
    }
719000
private static function debugHasKnownBlockType(array $block): bool
    {
        $result = false;

        if (array_key_exists(BlockSerializer::TYPE, $block) === true) {
            $type = $block[BlockSerializer::TYPE];

            $result =
                $type === BlockSerializer::TYPE__PROCEDURE ||
                $type === BlockSerializer::TYPE__AND_EXPRESSION ||
                $type === BlockSerializer::TYPE__OR_EXPRESSION ||
                $type === BlockSerializer::TYPE__IF_EXPRESSION;
        }

        return $result;
    }
818170
protected function cleanUpBlockLayout(Model\BlockInterface $block, array $data)
    {
        $clean = [];

        // TODO responsive padding
        if (isset($data[static::PADDING_TOP]) && 0 < $data[static::PADDING_TOP]) {
            $clean[static::PADDING_TOP] = $data[static::PADDING_TOP];
        }
        if (isset($data[static::PADDING_BOTTOM]) && 0 < $data[static::PADDING_BOTTOM]) {
            $clean[static::PADDING_BOTTOM] = $data[static::PADDING_BOTTOM];
        }

        $hasPreviousSize = $hasPreviousOffset = false;
        $previousSize = $previousOffset = null;

        /** @var Model\BlockInterface[] $blocks */
        $blocks = [];
        if (null !== $row = $block->getRow()) {
            $blocks = $row->getBlocks()->filter(function (Model\BlockInterface $b) use ($block) {
                return $b !== $block;
            });
        }

        $devices = array_reverse(array_keys(static::getDevices()));

        foreach ($devices as $device) {
            // Do we need to clear the previous block layout (which size is lower than 12)
            $clear = false;
            foreach ($blocks as $b) {
                $d = $b->getLayout();
                if (isset($d[$device][static::SIZE]) && 12 > $d[$device][static::SIZE]) {
                    $clear = true;
                    break;
                }
            }

            // If layout is set for this device
            if (!$clear && !isset($data[$device])) {
                continue;
            }

            $size = isset($data[$device][static::SIZE]) ? $data[$device][static::SIZE] : $previousSize;
            $offset = isset($data[$device][static::OFFSET]) ? $data[$device][static::OFFSET] : $previousOffset;

            $cleanDevice = [];

            if ($clear || ($hasPreviousSize && $previousSize != $size) || (!$hasPreviousSize && 12 > $size)) {
                $cleanDevice[static::SIZE] = $size;
            }
            if (($hasPreviousOffset && $previousOffset != $offset) || (!$previousOffset && 0 < $offset)) {
                $cleanDevice[static::OFFSET] = $offset;
            }

            if (!$hasPreviousSize && 12 > $size) {
                $hasPreviousSize = true;
            }
            if (!$hasPreviousOffset && 0 < $offset) {
                $hasPreviousOffset = true;
            }

            $previousSize = $size;
            $previousOffset = $offset;

            if (!empty($cleanDevice)) {
                $clean[$device] = $cleanDevice;
            }
        }

        return $clean;
    }
668950
public function getBlockTypeById(int $blockTypeId)
    {
        if ($this->_blockTypesById !== null && array_key_exists($blockTypeId, $this->_blockTypesById)) {
            return $this->_blockTypesById[$blockTypeId];
        }

        $result = $this->_createBlockTypeQuery()
            ->where(['id' => $blockTypeId])
            ->one();

        return $this->_blockTypesById[$blockTypeId] = $result ? new SuperTableBlockTypeModel($result) : null;
    }
418987
protected function delete_version_issue( $key, $type = '' ) {
		if ( true === $this->option_auto_delete && 'option' === $type ) {
			$this->delete_option( $key );
		}

		if ( true === $this->transient_auto_delete ) {
			return $this->delete_transient( $key );
		}
		return false;
	}
204844
public function updateBlockTypeSetName($btsName)
    {
        $btsName = (string) $btsName;
        $app = Application::getFacadeApplication();
        $db = $app->make(Connection::class);
        $db->update('BlockTypeSets', ['btsName' => $btsName], ['btsID' => $this->getBlockTypeSetID()]);
        $this->btsName = $btsName;
    }
57234
public function deleteByTagSlug( $parentId, $parentType, $tagSlug, $delete = false ) {

		$tag = $this->tagService->getBySlugType( $tagSlug, $parentType );

		$this->disableByModelId( $parentId, $parentType, $tag->id, $delete = false );

		return true;
	}
750940
protected function isBlockCompletable($Type)
    {
        $completable = \in_array($Type, $this->completable_blocks) || method_exists($this, 'block' . $Type . 'Complete');

        return $completable;
    }
869660
public function detach($contentTypeId, $blockTypeId)
    {
        try {
            $this->contentTypeBlocks->detach($contentTypeId, $blockTypeId);
        } catch (Exception $e) {
            return $this->handleException($e, trans('soda::errors.detach', ['object' => trans('soda::terminology.block')]));
        }

        return redirect()->route('soda.content-types.edit', [$contentTypeId, 'tab' => 'blocks'])->with('success', trans('soda::messages.detached', ['object' => trans('soda::terminology.block')]));
    }
971259
public function moveUp(Model\BlockInterface $block)
    {
        $row = $block->getRow();
        if (null === $row || $row->isFirst()) {
            throw new InvalidOperationException(
                "This block can't be moved to the top."
            );
        }

        $sibling = $this->editor->getRepository()->findSiblingRow($row, false);
        if (null === $sibling) {
            throw new InvalidOperationException(
                "The block can't be moved to the top as no sibling row has been found."
            );
        }

        $row->removeBlock($block);
        $sibling->addBlock($block);

        $this->editor
            ->getRowManager()
            ->fixBlocksPositions($row)
            ->fixBlocksPositions($sibling);

        return $sibling;
    }
708470
public function type($value)
    {
        if ($value instanceof SuperTableBlockType) {
            $this->typeId = $value->id;
        } else if ($value !== null) {
            $this->typeId = (new Query())
                ->select(['id'])
                ->from(['{{%supertableblocktypes}}'])
                ->where(Db::parseParam('id', $value))
                ->column();
        } else {
            $this->typeId = null;
        }

        return $this;
    }
30156
protected function validateBlockType($blockType)
    {
        if (!$blockType) {
            throw new Exception\InvalidArgumentException('The block type name must not be empty.');
        }
        if (!$blockType instanceof BlockTypeInterface) {
            if (!is_string($blockType)) {
                throw new Exception\UnexpectedTypeException($blockType, 'string or BlockTypeInterface', 'blockType');
            }
            if (!preg_match('/^[a-z][a-z0-9_]*$/iD', $blockType)) {
                throw new Exception\InvalidArgumentException(
                    sprintf(
                        'The "%s" string cannot be used as the name of the block type '
                        . 'because it contains illegal characters. '
                        . 'The valid block type name should start with a letter and only contain '
                        . 'letters, numbers and underscores ("_").',
                        $blockType
                    )
                );
            }
        }
    }
489120
public function validateBlock($blockType, $blockData)
    {
        /**
         * Default action for blocks that are not mentioned in a configuration
         */
        if (!array_key_exists($blockType, $this->rules->tools)) {
            throw new EditorJSException("Tool `$blockType` not found in the configuration");
        }

        $rule = $this->rules->tools[$blockType];

        return $this->validate($rule, $blockData);
    }