You are here

function modal_page_install in Modal 8.2

Same name and namespace in other branches
  1. 8.3 modal_page.install \modal_page_install()
  2. 8 modal_page.install \modal_page_install()
  3. 5.0.x modal_page.install \modal_page_install()
  4. 4.0.x modal_page.install \modal_page_install()
  5. 4.1.x modal_page.install \modal_page_install()

Implements hook_install().

File

./modal_page.install, line 275
Install, update and uninstall functions for the Modal Page.

Code

function modal_page_install() {
  $title = 'Thank you for installing Modal Page';
  $body = '<p>You can create your Modal at <a href="/admin/structure/modal/add">Structure » Modal » Add Modal</a></p>';
  $body .= '<p>Have fun :)</p>';
  $body .= '<p>If liked, give us a <a href="https://www.drupal.org/project/modal_page" target="blank">star</a></p>';
  $type = 'page';
  $pages = '/admin/*';
  $modal = Modal::create([
    'title' => $title,
    'body' => $body,
    'type' => $type,
    'pages' => $pages,
    'roles' => [
      'administrator',
      'authenticated',
    ],
  ]);
  $modal
    ->save();
  \Drupal::service('cache.render')
    ->invalidateAll();
  $messenger = \Drupal::messenger();
  $messenger
    ->addStatus(t('Modal Page load bootstrap.min.js by default, if this library is already loaded in other place, you can check a option <b>Don\'t load external JS Bootstrap</b> on <a href="@modal_page_settings">Modal Settings</a>', [
    '@modal_page_settings' => Url::fromRoute('modal_page.settings')
      ->toString(),
  ]));
}