private function deleteExistingTerms($vid = null)
    {
        $termStorage = $this->entityTypeManager->getStorage('taxonomy_term');
        //Load all vocabularies
        $vocabularies = $this->getVocabularies();

        if ($vid === 'all') {
            $vid = array_keys($vocabularies);
        } else {
            $vid = [$vid];
        }

        foreach ($vid as $item) {
            $vocabulary = $vocabularies[$item];
            $terms = $termStorage->loadTree($vocabulary->id());

            if (empty($terms)) {
                $this->getIo()->error(
                    sprintf(
                        $this->trans('commands.taxonomy.term.delete.messages.nothing'),
                        $item
                    )
                );
            } else {
                foreach ($terms as $term) {
                    $treal = $termStorage->load($term->tid);

                    if ($treal !== null) {
                        $this->getIo()->info(
                            sprintf(
                                $this->trans('commands.taxonomy.term.delete.messages.processing'),
                                $term->name
                            )
                        );
                        $treal->delete();
                    }
                }
            }
        }
    }
private function deleteExistingTerms($vid = null)
    {
        $termStorage = $this->entityTypeManager->getStorage('taxonomy_term');
        //Load all vocabularies
        $vocabularies = $this->getVocabularies();

        if ($vid === 'all') {
            $vid = array_keys($vocabularies);
        } else {
            $vid = [$vid];
        }

        foreach ($vid as $item) {
            $vocabulary = $vocabularies[$item];
            $terms = $termStorage->loadTree($vocabulary->id());

            if (empty($terms)) {
                $this->getIo()->error(
                    sprintf(
                        $this->trans('commands.taxonomy.term.delete.messages.nothing'),
                        $item
                    )
                );
            } else {
                foreach ($terms as $term) {
                    $treal = $termStorage->load($term->tid);

                    if ($treal !== null) {
                        $this->getIo()->info(
                            sprintf(
                                $this->trans('commands.taxonomy.term.delete.messages.processing'),
                                $term->name
                            )
                        );
                        $treal->delete();
                    }
                }
            }
        }
    }
private function deleteExistingTerms ( $ vid = null ) { $ termStorage = $ this -> entityTypeManager -> getStorage ( 'taxonomy_term' ) ; //Load all vocabularies $ vocabularies = $ this -> getVocabularies ( ) ; if ( $ vid === 'all' ) { $ vid = array_keys ( $ vocabularies ) ; } else { $ vid = [ $ vid ] ; } foreach ( $ vid as $ item ) { $ vocabulary = $ vocabularies [ $ item ] ; $ terms = $ termStorage -> loadTree ( $ vocabulary -> id ( ) ) ; if ( empty ( $ terms ) ) { $ this -> getIo ( ) -> error ( sprintf ( $ this -> trans ( 'commands.taxonomy.term.delete.messages.nothing' ) , $ item ) ) ; } else { foreach ( $ terms as $ term ) { $ treal = $ termStorage -> load ( $ term -> tid ) ; if ( $ treal !== null ) { $ this -> getIo ( ) -> info ( sprintf ( $ this -> trans ( 'commands.taxonomy.term.delete.messages.processing' ) , $ term -> name ) ) ; $ treal -> delete ( ) ; } } } } }
Destroy all existing terms

@param $vid
Destroy all existing terms