X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Ftaxonomy%2Fsrc%2FVocabularyListBuilder.php;h=b6f6921db43633e2324d9ce8ebecd0b25e07d282;hb=5b8bb166bfa98770daef9de5c127fc2e6ef02340;hp=e7c021b4d70aebcad7277d32b5c1444b3927e6ae;hpb=af6d1fb995500ae68849458ee10d66abbdcfb252;p=yaffs-website diff --git a/web/core/modules/taxonomy/src/VocabularyListBuilder.php b/web/core/modules/taxonomy/src/VocabularyListBuilder.php index e7c021b4d..b6f6921db 100644 --- a/web/core/modules/taxonomy/src/VocabularyListBuilder.php +++ b/web/core/modules/taxonomy/src/VocabularyListBuilder.php @@ -7,6 +7,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Render\RendererInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Url; @@ -45,6 +46,13 @@ class VocabularyListBuilder extends DraggableListBuilder { */ protected $renderer; + /** + * The messenger. + * + * @var \Drupal\Core\Messenger\MessengerInterface + */ + protected $messenger; + /** * Constructs a new VocabularyListBuilder object. * @@ -56,13 +64,20 @@ class VocabularyListBuilder extends DraggableListBuilder { * The entity manager service. * @param \Drupal\Core\Render\RendererInterface $renderer * The renderer service. + * @param \Drupal\Core\Messenger\MessengerInterface $messenger + * The messenger. */ - public function __construct(EntityTypeInterface $entity_type, AccountInterface $current_user, EntityTypeManagerInterface $entity_type_manager, RendererInterface $renderer = NULL) { + public function __construct(EntityTypeInterface $entity_type, + AccountInterface $current_user, + EntityTypeManagerInterface $entity_type_manager, + RendererInterface $renderer = NULL, + MessengerInterface $messenger) { parent::__construct($entity_type, $entity_type_manager->getStorage($entity_type->id())); $this->currentUser = $current_user; $this->entityTypeManager = $entity_type_manager; $this->renderer = $renderer; + $this->messenger = $messenger; } /** @@ -73,7 +88,8 @@ class VocabularyListBuilder extends DraggableListBuilder { $entity_type, $container->get('current_user'), $container->get('entity_type.manager'), - $container->get('renderer') + $container->get('renderer'), + $container->get('messenger') ); } @@ -123,7 +139,7 @@ class VocabularyListBuilder extends DraggableListBuilder { $header['label'] = t('Vocabulary name'); $header['description'] = t('Description'); - if ($this->currentUser->hasPermission('administer vocabularies')) { + if ($this->currentUser->hasPermission('administer vocabularies') && !empty($this->weightKey)) { $header['weight'] = t('Weight'); } @@ -161,7 +177,7 @@ class VocabularyListBuilder extends DraggableListBuilder { $this->renderer->addCacheableDependency($build['table'], $create_access); if ($create_access->isAllowed()) { $build['table']['#empty'] = t('No vocabularies available. Add vocabulary.', [ - ':link' => Url::fromRoute('entity.taxonomy_vocabulary.add_form')->toString() + ':link' => Url::fromRoute('entity.taxonomy_vocabulary.add_form')->toString(), ]); } else { @@ -189,7 +205,7 @@ class VocabularyListBuilder extends DraggableListBuilder { public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); - drupal_set_message(t('The configuration options have been saved.')); + $this->messenger->addStatus($this->t('The configuration options have been saved.')); } }