You are here

function composer_manager_file_dir in Composer Manager 7.2

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

Returns the realpath to the Composer file directory.

Parameters

bool $ensure_write_permission: Indicates whether the write permission should be ensured for the directory.

Return value

string

Throws

\RuntimeException

9 calls to composer_manager_file_dir()
composer_manager_lockfile_load in ./composer_manager.admin.inc
Loads the composer.lock file if it exists.
composer_manager_lock_file in ./composer_manager.module
Return the URI to the composer.lock file.
composer_manager_rebuild_form in ./composer_manager.admin.inc
Exposes a button that forces a rebuild of the composer.json file.
composer_manager_relative_json_property in ./composer_manager.writer.inc
Helper function for converting value into a relative path.
composer_manager_relative_vendor_dir in ./composer_manager.writer.inc
Returns the vendor directory relative to the composer file directory.

... See full list

3 string references to 'composer_manager_file_dir'
composer_manager_requirements in ./composer_manager.install
Implements hook_requirements().
composer_manager_settings_form_validate in ./composer_manager.admin.inc
Form validation handler for composer_manager_settings_form().
composer_manager_uninstall in ./composer_manager.install
Implements hook_uninstall().

File

./composer_manager.module, line 280
Provides consolidated management of third-party Composer-compatible packages required by contributed modules.

Code

function composer_manager_file_dir($ensure_write_permission = FALSE) {
  module_load_include('inc', 'composer_manager', 'composer_manager.writer');
  $scheme = file_default_scheme();

  // Composer can only be run on a locally mounted file system. If the scheme is
  // set to something different like S3, we fall back to the public scheme.
  if (!in_array($scheme, array(
    'public',
    'private',
  ))) {
    $scheme = 'public';
  }
  $dir_uri = variable_get('composer_manager_file_dir', $scheme . '://composer');
  if ($ensure_write_permission) {
    composer_manager_prepare_directory($dir_uri);
  }
  if (!($realpath = drupal_realpath($dir_uri))) {
    throw new \RuntimeException(t('Error resolving directory: @dir', array(
      '@dir' => $dir_uri,
    )));
  }
  return $realpath;
}