You are here

function simplemeta_page_bottom in Simple Meta 8.2

Same name and namespace in other branches
  1. 8 simplemeta.module \simplemeta_page_bottom()

Implements hook_page_bottom().

File

./simplemeta.module, line 46
Contains simplemeta.module.

Code

function simplemeta_page_bottom(array &$page_bottom) {
  $user = \Drupal::currentUser();
  if (simplemeta_need_to_inject() && $user
    ->hasPermission('administer simplemeta')) {
    if (!($entity = simplemeta_get_page_meta())) {
      $entity = SimplemetaEntity::create();
    }
    $form = \Drupal::service('entity.form_builder')
      ->getForm($entity, 'default');
    if (!empty($form['actions']['delete'])) {
      $current_path = \Drupal::service('path.current')
        ->getPath();
      $query = $form['actions']['delete']['#url']
        ->getOption('query');
      $query['destination'] = $current_path;
      $form['actions']['delete']['#url']
        ->setOption('query', $query);
    }
    $form['#attached']['library'][] = 'simplemeta/simplemeta';
    $page_bottom['simplemeta'] = $form;
  }
}