diff --git a/core/modules/taxonomy/src/Entity/Term.php b/core/modules/taxonomy/src/Entity/Term.php index d7e3ff1..16da170 100644 --- a/core/modules/taxonomy/src/Entity/Term.php +++ b/core/modules/taxonomy/src/Entity/Term.php @@ -4,6 +4,8 @@ use Drupal\Core\Entity\ContentEntityBase; use Drupal\Core\Entity\EntityChangedTrait; +use Drupal\Core\Entity\EntityPublishedInterface; +use Drupal\Core\Entity\EntityPublishedTrait; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\BaseFieldDefinition; @@ -37,6 +39,8 @@ * "bundle" = "vid", * "label" = "name", * "langcode" = "langcode", + * "status" = "status", + * "published" = "status", * "uuid" = "uuid" * }, * bundle_entity_type = "taxonomy_vocabulary", @@ -51,9 +55,10 @@ * permission_granularity = "bundle" * ) */ -class Term extends ContentEntityBase implements TermInterface { +class Term extends ContentEntityBase implements TermInterface, EntityPublishedInterface { use EntityChangedTrait; + use EntityPublishedTrait; /** * {@inheritdoc} @@ -105,11 +110,15 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { /** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */ $fields = parent::baseFieldDefinitions($entity_type); + // Add the published field. + $fields += static::publishedBaseFieldDefinitions($entity_type); + $fields['tid']->setLabel(t('Term ID')) ->setDescription(t('The term ID.')); $fields['uuid']->setDescription(t('The term UUID.')); + $fields['status'] ->setDisplayOptions('form', [ 'type' => 'boolean_checkbox', diff --git a/core/modules/taxonomy/src/TermForm.php b/core/modules/taxonomy/src/TermForm.php index 3872639..38ec039 100644 --- a/core/modules/taxonomy/src/TermForm.php +++ b/core/modules/taxonomy/src/TermForm.php @@ -90,13 +90,6 @@ public function form(array $form, FormStateInterface $form_state) { $form['#entity_builders']['update_status'] = '::updateStatus'; - $form['footer'] = [ - '#type' => 'container', - '#weight' => 99, - '#attributes' => [ - 'class' => ['taxonomy-term-form-footer'] - ] - ]; $form['status']['#group'] = 'footer'; return $form; @@ -144,6 +137,7 @@ public function save(array $form, FormStateInterface $form_state) { drupal_set_message($this->t('Created new term %term.', ['%term' => $view_link])); $this->logger('taxonomy')->notice('Created new term %term.', ['%term' => $term->getName(), 'link' => $edit_link]); break; + case SAVED_UPDATED: drupal_set_message($this->t('Updated term %term.', ['%term' => $view_link])); $this->logger('taxonomy')->notice('Updated term %term.', ['%term' => $term->getName(), 'link' => $edit_link]); @@ -158,8 +152,8 @@ public function save(array $form, FormStateInterface $form_state) { $form_state->setValue('parent', []); } - // If the number of parents has been reduced to one or none, do a check on the - // parents of every term in the vocabulary value. + // If the number of parents has been reduced to one or none, do a check + // on the parents of every term in the vocabulary value. $vocabulary = $form_state->get(['taxonomy', 'vocabulary']); if ($current_parent_count < $previous_parent_count && $current_parent_count < 2) { taxonomy_check_vocabulary_hierarchy($vocabulary, $form_state->getValues()); @@ -189,7 +183,7 @@ public function save(array $form, FormStateInterface $form_state) { * * @see \Drupal\taxonomy\TermForm::form() */ - function updateStatus($entity_type_id, TermInterface $term, array $form, FormStateInterface $form_state) { + public function updateStatus($entity_type_id, TermInterface $term, array $form, FormStateInterface $form_state) { $element = $form_state->getTriggeringElement(); if (isset($element['#published_status'])) { if ($element['#published_status'] == TRUE) {