diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php index 147b5c9..417cc19 100644 --- a/core/modules/node/src/NodeForm.php +++ b/core/modules/node/src/NodeForm.php @@ -7,6 +7,7 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Session\AccountInterface; use Drupal\user\PrivateTempStoreFactory; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -23,6 +24,13 @@ class NodeForm extends ContentEntityForm { protected $tempStoreFactory; /** + * The Current User object. + * + * @var \Drupal\Core\Session\AccountInterface + */ + protected $currentUser; + + /** * Constructs a NodeForm object. * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager @@ -33,10 +41,13 @@ class NodeForm extends ContentEntityForm { * The entity type bundle service. * @param \Drupal\Component\Datetime\TimeInterface $time * The time service. + * @param \Drupal\Core\Session\AccountInterface $current_user + * The current user. */ - public function __construct(EntityManagerInterface $entity_manager, PrivateTempStoreFactory $temp_store_factory, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) { + public function __construct(EntityManagerInterface $entity_manager, PrivateTempStoreFactory $temp_store_factory, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL, AccountInterface $current_user) { parent::__construct($entity_manager, $entity_type_bundle_info, $time); $this->tempStoreFactory = $temp_store_factory; + $this->currentUser = $current_user; } /** @@ -108,6 +119,7 @@ public function form(array $form, FormStateInterface $form_state) { '#weight' => -10, '#title' => $this->t('Status'), '#attributes' => ['class' => ['entity-meta__header']], + '#access' => $this->currentUser->hasPermission('administer nodes'), ]; $form['meta']['published'] = [ '#type' => 'item', diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme index 89d1828..cebf088 100644 --- a/core/themes/seven/seven.theme +++ b/core/themes/seven/seven.theme @@ -158,6 +158,7 @@ function seven_form_node_form_alter(&$form, FormStateInterface $form_state) { $form['advanced']['#type'] = 'container'; $form['meta']['#type'] = 'container'; + $form['meta']['#access'] = TRUE; $form['meta']['changed']['#wrapper_attributes']['class'][] = 'container-inline'; $form['meta']['author'] = [ '#type' => 'item',