entityTypeManager->getStorage('taxonomy_vocabulary')->create( [ 'name' => $this->getRandom()->sentences(mt_rand(1, $nameWords), true), 'description' => $this->getRandom()->sentences(), 'vid' => Unicode::strtolower($this->getRandom()->name()), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'weight' => mt_rand(0, 10), ] ); try { $vocabulary->save(); $vocabularies['success'][] = [ 'vid' => $vocabulary->id(), 'vocabulary' => $vocabulary->get('name'), ]; } catch (\Exception $error) { $vocabularies['error'][] = [ 'vid' => $vocabulary->id(), 'name' => $vocabulary->get('name'), 'error' => $error->getMessage() ]; } } return $vocabularies; } }