Security update for Core, with self-updated composer
[yaffs-website] / web / core / themes / seven / seven.theme
index 91c03e631fe58b71620319d15690bb1746ec2678..7d4a525f040b9b5f32789b6583b16fde03191412 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\media\MediaForm;
 
 /**
  * Implements hook_preprocess_HOOK() for HTML document templates.
@@ -23,7 +24,7 @@ function seven_preprocess_html(&$variables) {
 }
 
 /**
- * Implements hook_pre_render_HOOK() for menu-local-tasks templates.
+ * Implements hook_preprocess_HOOK() for menu-local-tasks templates.
  *
  * Use preprocess hook to set #attached to child elements
  * because they will be processed by Twig and drupal_render will
@@ -147,42 +148,34 @@ function seven_preprocess_maintenance_page(&$variables) {
 /**
  * Implements hook_form_BASE_FORM_ID_alter() for \Drupal\node\NodeForm.
  *
- * Changes vertical tabs to container and adds meta information.
+ * Changes vertical tabs to container.
  */
 function seven_form_node_form_alter(&$form, FormStateInterface $form_state) {
-  /** @var \Drupal\node\NodeInterface $node */
-  $node = $form_state->getFormObject()->getEntity();
-
   $form['#theme'] = ['node_edit_form'];
   $form['#attached']['library'][] = 'seven/node-form';
 
   $form['advanced']['#type'] = 'container';
-  $is_new = !$node->isNew() ? format_date($node->getChangedTime(), 'short') : t('Not saved yet');
-  $form['meta'] = [
-    '#attributes' => ['class' => ['entity-meta__header']],
-    '#type' => 'container',
-    '#group' => 'advanced',
-    '#weight' => -100,
-    'published' => [
-      '#type' => 'html_tag',
-      '#tag' => 'h3',
-      '#value' => $node->isPublished() ? t('Published') : t('Not published'),
-      '#access' => !$node->isNew(),
-      '#attributes' => [
-        'class' => ['entity-meta__title'],
-      ],
-    ],
-    'changed' => [
-      '#type' => 'item',
-      '#wrapper_attributes' => ['class' => ['entity-meta__last-saved', 'container-inline']],
-      '#markup' => '<h4 class="label inline">' . t('Last saved') . '</h4> ' . $is_new,
-    ],
-    'author' => [
-      '#type' => 'item',
-      '#wrapper_attributes' => ['class' => ['author', 'container-inline']],
-      '#markup' => '<h4 class="label inline">' . t('Author') . '</h4> ' . $node->getOwner()->getUsername(),
-    ],
-  ];
+  $form['meta']['#type'] = 'container';
+  $form['meta']['#access'] = TRUE;
+  $form['meta']['changed']['#wrapper_attributes']['class'][] = 'container-inline';
+  $form['meta']['author']['#wrapper_attributes']['class'][] = 'container-inline';
+
   $form['revision_information']['#type'] = 'container';
   $form['revision_information']['#group'] = 'meta';
 }
+
+/**
+ * Implements hook_form_BASE_FORM_ID_alter() for \Drupal\media\MediaForm.
+ */
+function seven_form_media_form_alter(&$form, FormStateInterface $form_state) {
+  $media_is_enabled = \Drupal::moduleHandler()->moduleExists('media');
+  // Only attach CSS from core if this form comes from Media core, and not from
+  // the contrib Media Entity 1.x branch.
+  if ($media_is_enabled && $form_state->getFormObject() instanceof MediaForm) {
+    // @todo Revisit after https://www.drupal.org/node/2892304 is in. It
+    // introduces a footer region to these forms which will allow for us to
+    // display a top border over the published checkbox by defining a
+    // media-edit-form.html.twig template the same way node does.
+    $form['#attached']['library'][] = 'seven/media-form';
+  }
+}