Remove a structure

@param int|string|array|\Paragraph\Model\Dashboard\Structure $structureOrPrimaryKeys
@return int
507353
public function delete( $structureOrPrimaryKeys )
    {
        if ( is_object( $structureOrPrimaryKeys ) )
        {
            $id = $structureOrPrimaryKeys->paragraph->id;
        }
        else if ( is_array( $structureOrPrimaryKeys ) )
        {
            if ( isset( $structureOrPrimaryKeys['paragraph']['id'] ) )
            {
                $id = $structureOrPrimaryKeys['paragraph']['id'];
            }
            else
            {
                $id = reset( $structureOrPrimaryKeys );
            }
        }
        else
        {
            $id = $structureOrPrimaryKeys;
        }

        return $this->getParagraphMapper()
                    ->delete( $id );
    }
849908
protected function _toArrayWithoutPrimaryKeys()
    {
        $ret = $this->toArray();
        unset($ret[$this->getModel()->getPrimaryKey()]);
        foreach ($this->_getSiblingRows() as $r) {
            $primaryKey = $r->getModel()->getPrimaryKey();
            if ($primaryKey) {
                unset($ret[$primaryKey]);
            }
        }
        return $ret;
    }
770724
public function addStructureNodeRelatedByStructureNodeId(ChildStructureNode $structureNodeRelatedByStructureNodeId)
    {
        if ($this->collStructureNodesRelatedByStructureNodeId === null) {
            $this->initStructureNodesRelatedByStructureNodeId();
        }

        if (!$this->getStructureNodesRelatedByStructureNodeId()->contains($structureNodeRelatedByStructureNodeId)) {
            // only add it if the **same** object is not already associated
            $this->collStructureNodesRelatedByStructureNodeId->push($structureNodeRelatedByStructureNodeId);
            $this->doAddStructureNodeRelatedByStructureNodeId($structureNodeRelatedByStructureNodeId);
        }

        return $this;
    }
890039
protected function selectmultiple_controls(structure $structure) {
        $output = '';

        // Bulk action button delete and bulk action button cancel.
        $buttondeleteoptions = array(
            'type' => 'button',
            'id' => 'selectmultipledeletecommand',
            'value' => get_string('deleteselected', 'mod_quiz'),
            'class' => 'btn btn-secondary'
        );
        $buttoncanceloptions = array(
            'type' => 'button',
            'id' => 'selectmultiplecancelcommand',
            'value' => get_string('cancel', 'moodle'),
            'class' => 'btn btn-secondary'
        );

        $groupoptions = array(
            'class' => 'btn-group selectmultiplecommand actions',
            'role' => 'group'
        );

        $output .= html_writer::tag('div',
                        html_writer::tag('button', get_string('deleteselected', 'mod_quiz'), $buttondeleteoptions) .
                        " " .
                        html_writer::tag('button', get_string('cancel', 'moodle'),
                $buttoncanceloptions), $groupoptions);

        $toolbaroptions = array(
            'class' => 'btn-toolbar',
            'role' => 'toolbar',
            'aria-label' => get_string('selectmultipletoolbar', 'quiz'),
        );

        // Select all/deselect all questions.
        $buttonselectalloptions = array(
            'role' => 'button',
            'id' => 'questionselectall',
            'class' => 'btn btn-link'
        );
        $buttondeselectalloptions = array(
            'role' => 'button',
            'id' => 'questiondeselectall',
            'class' => 'btn btn-link'
        );
        $output .= html_writer::tag('div',
                html_writer::tag('div',
                        html_writer::link('#', get_string('selectall', 'quiz'), $buttonselectalloptions) .
                        html_writer::tag('span', "/", ['class' => 'separator']) .
                        html_writer::link('#', get_string('selectnone', 'quiz'), $buttondeselectalloptions),
                        array('class' => 'btn-group selectmultiplecommandbuttons')),
                $toolbaroptions);
        return $output;
    }
566292
function delete_meta($meta_key) {
		return $this->edit_meta( $meta_key, function($id, $key, $path) {
			if ( $path ) {
				# Patch -- XXX unserialize and count up?
				$old = static::_get_meta($id, $key);
				if ( $old === false ) $old = array();
				$traverser = new RecursiveDataStructureTraverser($old);
				while ( $path ) {
					# nothing to delete?
					if ( ! $traverser->exists($path[0]) ) return;
					$traverser = $traverser->traverse_to(array($path[0]));
					array_shift($path);
				}
				$traverser->unset_on_parent();
				static::_set_meta($id, $key, $old);  # XXX reserialize and count down?
			} else {
				static::_delete_meta($id, $key);
			}
		});
	}
729280
public function delete($keys): int
    {
        if (!is_array($keys)) {
            $keys = [$keys];
        }
        return $this->handle->zRem($this->name, ...$keys);
    }
845266
public function getPrimaryKey()
    {
        $pks = [];
        foreach ($this->__primaryKeys as $pk) {
            if (is_object($this->$pk)) {
                $traits = class_uses($this->$pk);
                if (isset($traits['Ornament\Model'])
                    || isset($traits['Ornament\JsonModel'])
                ) {
                    $pks[] = $this->$pk->getPrimaryKey();
                } else {
                    $pks[] = "{$this->$pk}";
                }
            } else {
                $pks[] = $this->$pk;
            }
        }
        return count($pks) == 1 ? $pks[0] : $pks;
    }
194643
public function delete( $structureOrName )
    {
        $path = $this->getSavePath();

        if ( is_object( $structureOrName ) )
        {
            $name = $structureOrName->name;
        }
        else if ( is_array( $structureOrName ) )
        {
            $name = $structureOrName['name'];
        }
        else
        {
            $name = (string) $structureOrName;
        }

        if ( ! is_file( $path . $name ) )
        {
            return 0;
        }

        return (int) @ unlink( $path . $name );
    }
687585
private void removeHasOneToBothPrimaryAndForeignKey() {
		String[] primaryKeys = model.getPrimaryAttributes();
		String[] hasOne = model.getHasOne();
		String[] hasOneLocal = model.getHasOneLocalColumn();
		String[] hasOneReferenced = model.getHasOneReferencedColumn();
		for(String pk : primaryKeys){
			int pkIndex = CStringUtils.indexOf(hasOneLocal, pk);
			if(pkIndex >= 0){
				System.out.println("\n"+pk+" is a primary key of ["+model.getTableName()+"] ("+hasOneLocal[pkIndex]+")"
						+ "and foreign key to ["+hasOne[pkIndex]+"]("+hasOneReferenced[pkIndex]+")");
				System.out.println("removing ["+hasOne[pkIndex]+"] from ["+model.getTableName()+"]");
				model = removeFromHasOne(model, hasOne[pkIndex]);
			}
		}
	}
397421
protected function internalRemoveItem(&$normalizedKey)
    {
        /** @var Cache $cache  */
        $cache = Core::make($this->cacheName);
        $item = $cache->getItem('zend/'.$normalizedKey);

        return $item->clear();
    }
710964
def remove_structure(instance_or_number)
      raise ArgumentError, "Invalid argument 'instance_or_number'. Expected a ROI Instance or an Integer (ROI Number). Got #{instance_or_number.class}." unless [ROI, Integer].include?(instance_or_number.class)
      s_instance = instance_or_number
      if instance_or_number.is_a?(Integer)
        s_instance = structure(instance_or_number)
      end
      index = @structures.index(s_instance)
      if index
        @structures.delete_at(index)
        s_instance.remove_references
      end
    end
413842
public static function remove(array &$subjectArray, $keys)
    {
        $original =& $subjectArray;
        foreach ((array) $keys as $key) {
            self::removeSegments($subjectArray, $key);

            $subjectArray =& $original;
        }
    }
130471
public function setPrimaryKey(PrimaryKey $primaryKey)
    {
        foreach ($primaryKey->getColumnNames() as $columnName) {
            $this->getColumn($columnName)->setNotNull(true);
        }

        $this->primaryKey = $primaryKey;
    }
1072585
public function delete($userKey, $optParams = array()) {
      $params = array('userKey' => $userKey);
      $params = array_merge($params, $optParams);
      $data = $this->__call('delete', array($params));
      return $data;
    }
706343
public function delete(EntityDefinition $definition, array $ids, WriteContext $writeContext): DeleteResult
    {
        $this->validateWriteInput($ids);

        $commandQueue = new WriteCommandQueue();

        $fields = $definition->getPrimaryKeys();

        $resolved = [];
        foreach ($ids as $raw) {
            $mapped = [];

            /** @var Field $field */
            foreach ($fields as $field) {
                if (!($field instanceof StorageAware)) {
                    continue;
                }

                if (array_key_exists($field->getPropertyName(), $raw)) {
                    $mapped[$field->getStorageName()] = $raw[$field->getPropertyName()];
                    continue;
                }

                if ($field instanceof ReferenceVersionField) {
                    $mapped[$field->getStorageName()] = $writeContext->getContext()->getVersionId();
                    continue;
                }

                if ($field instanceof VersionField) {
                    $mapped[$field->getStorageName()] = $writeContext->getContext()->getVersionId();
                    continue;
                }

                $fieldKeys = $fields
                    ->filter(function (Field $field) {
                        return !$field instanceof VersionField && !$field instanceof ReferenceVersionField;
                    })
                    ->map(function (Field $field) {
                        return $field->getPropertyName();
                    });

                throw new IncompletePrimaryKeyException($fieldKeys);
            }

            $resolved[] = $mapped;
        }

        if (!$definition instanceof MappingEntityDefinition) {
            $restrictions = $this->foreignKeyResolver->getAffectedDeleteRestrictions($definition, $resolved, $writeContext->getContext());

            if (!empty($restrictions)) {
                $restrictions = array_map(function ($restriction) {
                    return new RestrictDeleteViolation($restriction['pk'], $restriction['restrictions']);
                }, $restrictions);

                throw new RestrictDeleteViolationException($definition, $restrictions, $this->registry);
            }
        }

        $cascades = [];
        if (!$definition instanceof MappingEntityDefinition) {
            $cascadeDeletes = $this->foreignKeyResolver->getAffectedDeletes($definition, $resolved, $writeContext->getContext());

            $cascadeDeletes = array_column($cascadeDeletes, 'restrictions');
            foreach ($cascadeDeletes as $cascadeDelete) {
                $cascades = array_merge_recursive($cascades, $cascadeDelete);
            }

            foreach ($cascades as $affectedDefinitionClass => &$cascade) {
                $affectedDefinition = $this->registry->get($affectedDefinitionClass);

                $cascade = array_map(function ($key) use ($affectedDefinition) {
                    $payload = $key;

                    if (!\is_array($key)) {
                        $payload = ['id' => $key];
                    }

                    return new EntityWriteResult($key, $payload, $affectedDefinition, null);
                }, $cascade);
            }
        }

        $skipped = [];
        foreach ($resolved as $mapped) {
            $mappedBytes = array_map(function ($id) {
                return Uuid::fromHexToBytes($id);
            }, $mapped);

            $existence = $this->gateway->getExistence($definition, $mappedBytes, [], $commandQueue);

            if (!$existence->exists()) {
                $skipped[$definition->getClass()][] = new EntityWriteResult($mapped, $mapped, $definition, $existence);
                continue;
            }

            $commandQueue->add(
                $definition,
                new DeleteCommand(
                    $definition,
                    $mappedBytes,
                    $existence
                )
            );
        }

        $writeContext->setLanguages($this->languageLoader->loadLanguages());
        $identifiers = $this->getWriteResults($commandQueue);
        $this->gateway->execute($commandQueue->getCommandsInOrder(), $writeContext);

        return new DeleteResult(
            array_merge_recursive($identifiers, $cascades),
            $skipped
        );
    }
614074
public function getPrimaryKey()
    {
        $pk = array();
        foreach ($this->columnList as $col) {
            if ($col->isPrimaryKey()) {
                $pk[] = $col;
            }
        }

        return $pk;
    }
350413
public function prune($structureNode = null)
    {
        if ($structureNode) {
            $this->addUsingAlias(StructureNodeTableMap::COL_ID, $structureNode->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }