You are here

function composer_manager_prepare_directory in Composer Manager 7.2

Same name and namespace in other branches
  1. 6.2 composer_manager.writer.inc \composer_manager_prepare_directory()
  2. 6 composer_manager.writer.inc \composer_manager_prepare_directory()
  3. 7 composer_manager.writer.inc \composer_manager_prepare_directory()

Ensures the directory is created and protected via .htaccess if necessary.

Parameters

string $directory: The URI or path to the directory being prepared.

bool $for_write: Whether the directory needs write permissions.

Return value

bool

4 calls to composer_manager_prepare_directory()
composer_manager_file_dir in ./composer_manager.module
Returns the realpath to the Composer file directory.
composer_manager_put_file in ./composer_manager.writer.inc
Writes the composer.json file in the specified directory.
composer_manager_settings_form_validate in ./composer_manager.admin.inc
Form validation handler for composer_manager_settings_form().
composer_manager_vendor_dir in ./composer_manager.module
Returns the path to the vendor directory.

File

./composer_manager.writer.inc, line 244
Functions related to the creation of the consolidated composer.json file.

Code

function composer_manager_prepare_directory($directory, $for_write = FALSE) {
  $options = $for_write ? FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS : FILE_CREATE_DIRECTORY;
  if (!file_prepare_directory($directory, $options)) {
    return FALSE;
  }
  if (0 === strpos($directory, 'public://')) {
    file_create_htaccess($directory, TRUE);
  }
  return TRUE;
}