You are here

function opigno_lms_install in Opigno LMS 3.x

Same name and namespace in other branches
  1. 8.2 opigno_lms.install \opigno_lms_install()
  2. 8 opigno_lms.install \opigno_lms_install()
  3. 7 opigno_lms.install \opigno_lms_install()

Implements hook_install().

Performs actions to set up the site for this profile.

Throws

\Drupal\Core\Extension\MissingDependencyException

See also

system_install()

File

./opigno_lms.install, line 25
Install, update and uninstall functions for the "opigno_lms" installation profile.

Code

function opigno_lms_install() {
  \Drupal::service('module_installer')
    ->install([
    'opigno_alter_entity_autocomplete',
  ]);
  $config = \Drupal::configFactory();

  // Disable the user pictures on nodes.
  $config
    ->getEditable('system.theme.global')
    ->set('features.node_user_picture', FALSE)
    ->save(TRUE);

  // Allow visitor account creation, but with administrative approval.
  $config
    ->getEditable('user.settings')
    ->set('register', UserInterface::REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)
    ->save(TRUE);

  // Set default home page.
  $config
    ->getEditable('system.site')
    ->set('page.front', '/node')
    ->save(TRUE);

  // Set theme logo path.
  $theme_path = drupal_get_path("theme", "aristotle");
  $logo_path = $theme_path . "/assets/Logo-Opigno-white.svg";
  $config
    ->getEditable('aristotle.settings')
    ->set('logo.path', $logo_path)
    ->save(TRUE);
  $logo_second = $theme_path . "/assets/Logo-Opigno-3-dark.svg";
  $config
    ->getEditable('aristotle.settings')
    ->set('logo_path2', $logo_second)
    ->save(TRUE);

  // Assign user 1 the "administrator" role.
  $user = User::load(1);
  $user
    ->addRole('administrator');
  $user
    ->save();

  // Copy user login page background image to public folder.
  $image = file_get_contents(drupal_get_path("theme", "aristotle") . "/assets/Trient-0014.jpg");
  file_save_data($image, 'public://Trient-0014.jpg', TRUE);

  // Copy user login page background image to public folder.
  $image = file_get_contents(drupal_get_path("profile", "opigno_lms") . "/images/Opigno_Image_connexion_1600-829_2.jpg");
  file_save_data($image, 'public://Opigno_Image_connexion_1600-829_2.jpg', TRUE);
  $dompdf_autoloaders = [
    'libraries/dompdf/src/Autoloader.php',
    'profiles/opigno_lms/libraries/dompdf/src/Autoloader.php',
  ];
  foreach ($dompdf_autoloaders as $dompdf_autoloader) {
    if (file_exists($dompdf_autoloader)) {

      // Load dompdf for the entity_print install.
      require_once $dompdf_autoloader;
      \Dompdf\Autoloader::register();

      // Install entity_print.
      \Drupal::service('module_installer')
        ->install([
        'entity_print',
      ]);
      break;
    }
  }
}