Same name in other branches
  1. 5.0.x advagg.install \advagg_install()
  2. 6.0.x advagg.install \advagg_install()
  3. 7.x-1.x advagg.install \advagg_install()
  4. 7.x-2.x advagg.install \advagg_install()
  5. 8.x-2.x advagg.install \advagg_install()
  6. 8.x-4.x advagg.install \advagg_install()

Implements hook_install().

Fichier

./advagg.install, line 15

Code

function advagg_install() {
    // Make sure permissions for dirs are correct. Needed if installed via drush.
    $stat_public = stat('public://');
    // Check if this folder already exists - could be the case on re-install.
    if (!file_exists('public://css')) {
        \Drupal::service('file_system')->mkdir('public://css');
    }
    $stat_css = stat('public://css');
    // Check if this folder already exists - could be the case on re-install.
    if (!file_exists('public://js')) {
        \Drupal::service('file_system')->mkdir('public://js');
    }
    $stat_js = stat('public://js');
    if (isset($stat_public['uid'])) {
        if (isset($stat_css['uid']) && $stat_public['uid'] != $stat_css['uid']) {
            @chown($stat_css[0], $stat_public['uid']);
        }
        if (isset($stat_js['uid']) && $stat_public['uid'] != $stat_js['uid']) {
            @chown($stat_js[0], $stat_public['uid']);
        }
    }
    if (isset($stat_public['gid'])) {
        if (isset($stat_css['gid']) && $stat_public['gid'] != $stat_css['gid']) {
            @chgrp($stat_css[0], $stat_public['gid']);
        }
        if (isset($stat_js['uid']) && $stat_public['gid'] != $stat_js['gid']) {
            @chgrp($stat_js[0], $stat_public['gid']);
        }
    }
}