public static function HudtInternal::getStoragePath in Hook Update Deploy Tools 8
Same name and namespace in other branches
- 7 src/HudtInternal.php \HookUpdateDeployTools\HudtInternal::getStoragePath()
Gets the path for where import files are stored for a given storage type.
Parameters
string $storage_type: The type of storage (menu, panel, rule...).
bool $safe_check: Determines whether getting the path should be safe:
- FALSE (default) : An \Exception will be thrown if no path.
- TRUE : No exception will be thrown and message will be returned.
Return value
string The path to the storage module for the storage type.
Throws
HudtException If the path is not available and it is not a $safe_check
8 calls to HudtInternal::getStoragePath()
- hook_update_deploy_tools_admin in ./
hook_update_deploy_tools.module - The callback function creates an admin form for a menu hook.
- HudtInternal::canReadFile in src/
HudtInternal.php - Checks to see if a storagefile can be read.
- HudtInternal::readFileToArray in src/
HudtInternal.php - Read the contents of a file into an array of one element per line.
- HudtInternal::readFileToString in src/
HudtInternal.php - Read the contents of a file into a string for the entire contents.
- Menus::import in src/
Menus.php - Imports menus using the menu_import module & template.
File
- src/
HudtInternal.php, line 143
Class
- HudtInternal
- Methods for processes internal to Hook Deploy Update Tools.
Namespace
HookUpdateDeployToolsCode
public static function getStoragePath($storage_type, $safe_check = FALSE) {
$var_storage = self::getStorageVars();
$t = get_t();
if (!empty($var_storage[$storage_type])) {
// Storage is known. Look for specific storage module.
$storage_module = variable_get($var_storage[$storage_type], '');
// Might have come up empty so look for default storage.
$storage_module = !empty($storage_module) ? $storage_module : variable_get($var_storage['default'], '');
$storage_module = check_plain($storage_module);
// Might still have come up empty, so look for site_deploy.
$storage_module = !empty($storage_module) ? $storage_module : 'site_deploy';
if (module_exists($storage_module)) {
// Get the path from the storage.
$module_path = drupal_get_path('module', $storage_module);
$storage_path = "{$module_path}/{$storage_type}_source/";
return $storage_path;
}
elseif ($safe_check) {
return $t('The module "@module" does not exits, please add it or adjust accordingly.', array(
'@module' => $storage_module,
));
}
else {
// Storage module does not exist, throw exception, fail update.
$variables = array(
'!path' => '/admin/config/development/hook_update_deploy_tools',
'!storage' => $storage_type,
'%module' => $storage_module,
);
$message = "The storage module '%module' does not exist. Visit !path to set the correct module for !storage import.";
throw new HudtException($message, $variables, WATCHDOG_ERROR, TRUE);
}
}
else {
// No storage of this type, throw exception, call this a failure.
$message = 'There is no storage of type !type to read/write. Internal Hook Update Deploy Tools error.';
$variables = array(
'!type' => $storage_type,
);
throw new HudtException($message, $variables, WATCHDOG_ERROR, TRUE);
}
}