You are here

public static function ConfigBit::actionArchiveFiles in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 8.4

Same name and namespace in other branches
  1. 8.8 src/Config/ConfigBit.php \Drupal\varbase\Config\ConfigBit::actionArchiveFiles()
  2. 8.5 src/Config/ConfigBit.php \Drupal\varbase\config\ConfigBit::actionArchiveFiles()
  3. 8.6 src/Config/ConfigBit.php \Drupal\varbase\config\ConfigBit::actionArchiveFiles()
  4. 8.7 src/Config/ConfigBit.php \Drupal\varbase\config\ConfigBit::actionArchiveFiles()
  5. 9.0.x src/Config/ConfigBit.php \Drupal\varbase\Config\ConfigBit::actionArchiveFiles()

Applay the action of archive files to the given config bit file.

Parameters

string $config_bit_file_name: Config bit file name in the root configbit folder.

string $condition_name: Condition name in the config bit file.

string|bool $condition_value: Condition value for the condition name in the config bit file.

File

src/Config/ConfigBit.php, line 113

Class

ConfigBit
Defines config bit to help in managing custom config which used in install.

Namespace

Drupal\varbase\config

Code

public static function actionArchiveFiles($config_bit_file_name, $condition_name, $condition_value, $type = 'profile', $project = 'varbase') {
  $config_bit_data = ConfigBit::getConfigBit($config_bit_file_name, $type, $project);
  if (isset($config_bit_data['type']) && ($config_bit_data['type'] = 'action' && isset($config_bit_data['action']) && isset($config_bit_data['action']['archive_files']) && isset($config_bit_data['action']['archive_files']['when']) && isset($config_bit_data['action']['archive_files']['when'][$condition_name]) && $config_bit_data['action']['archive_files']['when'][$condition_name] == $condition_value && isset($config_bit_data['action']['archive_files']['files']))) {
    foreach ($config_bit_data['action']['archive_files']['files'] as $language_config_file) {
      $config_file = drupal_get_path($type, $project) . '/' . $language_config_file;
      if (file_exists($config_file)) {
        $config_file_backup = $config_file . $config_bit_data['action']['archive_files']['archive_extensiton'];
        file_unmanaged_move($config_file, $config_file_backup);
      }
    }
  }
}