X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FUtils%2FCreate%2FVocabularyData.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FUtils%2FCreate%2FVocabularyData.php;h=5a7dc3ef1cd71248fd37e1a1aff35e3b659171cb;hp=9b0cca4aff955550e8e64f2d5bb14e73ec82667e;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/drupal/console/src/Utils/Create/VocabularyData.php b/vendor/drupal/console/src/Utils/Create/VocabularyData.php index 9b0cca4af..5a7dc3ef1 100644 --- a/vendor/drupal/console/src/Utils/Create/VocabularyData.php +++ b/vendor/drupal/console/src/Utils/Create/VocabularyData.php @@ -20,25 +20,6 @@ use Drupal\Core\Language\LanguageInterface; */ class VocabularyData extends Base { - /** - * Vocabularies constructor. - * - * @param EntityTypeManagerInterface $entityManager - * @param EntityFieldManagerInterface $entityFieldManager - * @param DateFormatterInterface $dateFormatter - */ - public function __construct( - EntityTypeManagerInterface $entityManager, - EntityFieldManagerInterface $entityFieldManager, - DateFormatterInterface $dateFormatter - ) { - parent::__construct( - $entityManager, - $entityFieldManager, - $dateFormatter - ); - } - /** * Create and returns an array of new Vocabularies. * @@ -52,31 +33,25 @@ class VocabularyData extends Base $nameWords ) { $vocabularies = []; - for ($i=0; $i<$limit; $i++) { - - // Create a vocabulary. - $vocabulary = $this->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), - ] - ); - + for ($i = 0; $i < $limit; $i++) { try { + // Create a vocabulary. + $vocabulary = $this->entityTypeManager->getStorage('taxonomy_vocabulary')->create( + [ + 'name' => $this->getRandom()->sentences(mt_rand(1, $nameWords), true), + 'description' => $this->getRandom()->sentences(mt_rand(1, $nameWords)), + 'vid' => Unicode::strtolower($this->getRandom()->name()), + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, + 'weight' => mt_rand(0, 10), + ] + ); $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() - ]; + $vocabularies['error'][] = $error->getMessage(); } }