You are here

function colorbox_library_test_install in Colorbox 8

Implements hook_install().

File

tests/modules/colorbox_library_test/colorbox_library_test.install, line 14
Install file for the colorbox library test module.

Code

function colorbox_library_test_install() {
  $library_folder = Settings::get('file_public_path') . '/libraries';
  $zip_file = $library_folder . '/colorbox.zip';
  $colorbox_folder = $library_folder . '/colorbox';
  if (file_exists($colorbox_folder)) {
    return;
  }
  \Drupal::service('file_system')
    ->prepareDirectory($library_folder, FileSystemInterface::MODIFY_PERMISSIONS | FileSystemInterface::CREATE_DIRECTORY);
  copy('https://github.com/jackmoore/colorbox/archive/master.zip', $zip_file);
  $zip = new \ZipArchive();
  $zip
    ->open($zip_file);
  $zip
    ->extractTo($library_folder);
  rename($library_folder . '/colorbox-master', $colorbox_folder);
}