You are here

function hackedProject::locate_local_project in Hacked! 8.2

Locate the base directory of the local project.

1 call to hackedProject::locate_local_project()
hackedProject::hash_local_project in src/hackedProject.php
Hash the local version of the project.

File

src/hackedProject.php, line 179

Class

hackedProject
Encapsulates a Hacked! project.

Namespace

Drupal\hacked

Code

function locate_local_project() {

  // we need a remote project to do this :(
  $this
    ->hash_remote_project();

  // Do we have at least some modules to check for:
  if (!is_array($this->project_info['includes']) || !count($this->project_info['includes'])) {
    return FALSE;
  }

  // If this project is drupal it, we need to handle it specially
  if ($this->project_type != 'core') {
    $includes = array_keys($this->project_info['includes']);
    $include = array_shift($includes);
    $include_type = $this->project_info['project_type'];
  }
  else {

    // Just use the system module to find where we've installed drupal
    $include = 'system';
    $include_type = 'module';
  }

  //$include = 'image_captcha';
  $path = drupal_get_path($include_type, $include);

  // Now we need to find the path of the info file in the downloaded package:
  $temp = '';
  foreach ($this->remote_files->files as $file) {
    if (preg_match('@(^|.*/)' . $include . '.info.yml$@', $file)) {
      $temp = $file;
      break;
    }
  }

  // How many '/' were in that path:
  $slash_count = substr_count($temp, '/');
  $back_track = str_repeat('/..', $slash_count);
  return realpath($path . $back_track);
}