Bulk delete all tag instances for a component or tag area

@param string $component
@param string $itemtype (optional)
@param int $contextid (optional)
173924
public static function delete_instances($component, $itemtype = null, $contextid = null) {
        global $DB;

        $sql = "SELECT ti.*, t.name, t.rawname, t.isstandard
                  FROM {tag_instance} ti
                  JOIN {tag} t
                    ON ti.tagid = t.id
                 WHERE ti.component = :component";
        $params = array('component' => $component);
        if (!is_null($contextid)) {
            $sql .= " AND ti.contextid = :contextid";
            $params['contextid'] = $contextid;
        }
        if (!is_null($itemtype)) {
            $sql .= " AND ti.itemtype = :itemtype";
            $params['itemtype'] = $itemtype;
        }

        if ($taginstances = $DB->get_records_sql($sql, $params)) {
            static::delete_instances_as_record($taginstances);
        }
    }
730638
protected function copyArrayType(ArrayType $arrayType, ObjectType $itemType) : ArrayType {
        return new ArrayType(
            $arrayType->getIterableKeyType(),
            $itemType,
            $arrayType->isItemTypeInferredFromLiteralArray(),
            $arrayType->isCallable()
        );
    }
139492
function deleteStoredClassAttribute( $contentClassAttribute, $version = null )
    {
        $contentClassAttributeID = $contentClassAttribute->attribute( 'id' );
        eZEnumValue::removeAllElements( $contentClassAttributeID, $version );

    }
244539
public function deleteComponentAction(Component $component)
    {
        execute(new RemoveComponentCommand($component));

        return cachet_redirect('dashboard.components')
            ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.components.delete.success')));
    }
68835
private function setDataForItem($itemId, $tags, $thisExisting)
    {
        if ($tags === null) {
            $tagIds = [];
        } else {
            $tagIds = \array_keys($tags);
        }

        // First pass, delete all not mentioned anymore.
        $valuesToRemove = \array_diff($thisExisting, $tagIds);
        if ($valuesToRemove) {
            $this->connection
                ->createQueryBuilder()
                ->delete('tl_metamodel_tag_relation')
                ->where('att_id=:attId')
                ->andWhere('item_id=:itemId')
                ->andWhere('value_id IN (:valueIds)')
                ->setParameter('attId', $this->get('id'))
                ->setParameter('itemId', $itemId)
                ->setParameter('valueIds', $valuesToRemove, Connection::PARAM_STR_ARRAY)
                ->execute();
        }

        // Second pass, add all new values in a row.
        $valuesToAdd  = \array_diff($tagIds, $thisExisting);
        $insertValues = [];
        if ($valuesToAdd) {
            foreach ($valuesToAdd as $valueId) {
                $insertValues[] = [
                    'attId'   => $this->get('id'),
                    'itemId'  => $itemId,
                    'sorting' => (int) $tags[$valueId]['tag_value_sorting'],
                    'valueId' => $valueId
                ];
            }
        }

        // Third pass, update all sorting values.
        $valuesToUpdate = \array_diff($tagIds, $valuesToAdd);
        if ($valuesToUpdate) {
            $query = $this->connection
                ->createQueryBuilder()
                ->update('tl_metamodel_tag_relation')
                ->set('value_sorting', ':sorting')
                ->where('att_id=:attId')
                ->andWhere('item_id=:itemId')
                ->andWhere('value_id=:valueId')
                ->setParameter('attId', $this->get('id'))
                ->setParameter('itemId', $itemId);

            foreach ($valuesToUpdate as $valueId) {
                if (!array_key_exists('tag_value_sorting', $tags[$valueId])) {
                    continue;
                }
                $query
                    ->setParameter('sorting', (int) $tags[$valueId]['tag_value_sorting'])
                    ->setParameter('valueId', $valueId)
                    ->execute();
            }
        }

        return $insertValues;
    }
1224639
public static function get_showstandard($component, $itemtype) {
        $itemtypes = self::get_areas();
        if (array_key_exists($itemtype, $itemtypes)) {
            if (!array_key_exists($component, $itemtypes[$itemtype])) {
                $component = key($itemtypes[$itemtype]);
            }
            return $itemtypes[$itemtype][$component]->showstandard;
        }
        return core_tag_tag::BOTH_STANDARD_AND_NOT;
    }
399213
function removeItem( $itemID )
    {
        $item = eZProductCollectionItem::fetch( $itemID );
        if ( is_object( $item ) && $this->attribute( 'productcollection_id' ) == $item->attribute( 'productcollection_id' ) )
        {
            $item->remove();
        }
    }
157513
public function deleteItem(ItemUUID $uuid)
    {
        $itemUUID = $uuid->composeUUID();
        $this->elementsToDelete[$itemUUID] = $uuid;
        unset($this->elementsToUpdate[$itemUUID]);
    }
981410
public function deleteCollectionItem($collectionId, $itemId, $accessToken)
    {
        if (!$this->apiVersionIsGreaterThanV3()) {
            throw new EndpointNotSupportedByApiVersionException();
        }

        if (!is_string($itemId)) {
            throw new InvalidTypeException('Item ID', 'string', gettype($itemId));
        }

        return $this->delete(sprintf('collections/%s/items/%s', $collectionId, $itemId), [], $accessToken);
    }
1040476
protected function removeAllItems($type) {
        $names = [];
        $query = (new Query)
            ->select(['name'])
            ->from($this->itemTable)
            ->where(['type' => $type]);
        foreach ($query->all($this->db) as $row) {
            $names[] = $row['name'];
        }

        if (empty($names)) {
            return;
        }
        $key = $type == Item::TYPE_PERMISSION ? 'child' : 'parent';
        $this->db->getCollection($this->itemChildTable)->remove([$key => $names]);
        $this->db->getCollection($this->assignmentTable)->remove(['item_name' => $names]);
        $this->db->getCollection($this->itemTable)->remove(['type' => $type]);
    }
1283833
@Override
    public void removeItem(int itemID) {
        super.removeItem(itemID);
        ratingsItem.remove(itemID);
        itemsStats.remove(itemID);
    }
52531
@Override
	public synchronized void deleteAllDataForContextAndType(int contextId, int type) throws DatabaseException {
    	try {
			psDeleteAllDataForContextAndType.setInt(1, contextId);
			psDeleteAllDataForContextAndType.setInt(2, type);
			psDeleteAllDataForContextAndType.executeUpdate();
		} catch (SQLException e) {
			throw new DatabaseException(e);
		}
    }
837514
@Override
    public void destroy(Contextual<?> contextual) {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "destroy(Contextual)", new Object[] { contextual, this });

        final Map<String, InstanceAndContext<?>> storage = getStorage(false);

        if (storage != null) {
            final String contextId = getContextualId(contextual);

            InstanceAndContext<?> data = this.getByContextual(storage, contextual);

            if (data != null) {
                storage.remove(contextId);
                destroyItem(contextId, data);
            }
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, "destroy(Contextual)");
    }
796852
protected static function delete($record) {
        global $DB;

        core_tag_tag::delete_instances($record->component, $record->itemtype);

        $DB->delete_records('tag_area',
                array('itemtype' => $record->itemtype,
                    'component' => $record->component));

        // Reset cache.
        cache::make('core', 'tags')->delete('tag_area');
    }
404151
function (item) {
            var ri,
                key = this._getKeyForItem(item),
                list = this.$renderedItems;
            if (key) {
                list = this.$renderedItemsMap[key];
            }
            for (var i = 0; i < list.length; i++) {
                ri = list[i];
                if (key || ri.item === item) {
                    this.$parent.removeChild(ri.component);
                    list.splice(i, 1);
                    ri.component.destroy();
                    return;
                }
            }
        }
1055924
public void removeFromAccordion(JComponent component) 
    {
        CollapsiblePanel collapsiblePanel = collapsiblePanels.get(component);
        if (collapsiblePanel != null)
        {
            contentPanel.remove(collapsiblePanel);
            collapsiblePanels.remove(component);
            revalidate();
        }
    }
1312328
@Override
    @SuppressWarnings("deprecation")
    public boolean canRemoveItem( String itemName ) {
        CheckArg.isNotNull(itemName, "itemName");
        Name childName = context.getValueFactories().getNameFactory().create(itemName);
        return nodeTypes().canRemoveItem(this.name, null, childName, true);
    }