Skip to content

Commit

Permalink
Drupal finder constants (#172)
Browse files Browse the repository at this point in the history
* [console] Fix package.

* [console] Improve CONSTANT definition.
  • Loading branch information
jmolivas committed Jun 22, 2017
1 parent 2b86939 commit 0dca9fd
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/Utils/DrupalFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,37 @@ class DrupalFinder extends DrupalFinderBase
{
public function locateRoot($start_path)
{
$vendorDir = 'vendor';
if (parent::locateRoot($start_path)) {
$composerRoot = $this->getComposerRoot();
$vendorDir = str_replace(
$composerRoot .'/', '', $this->getVendorDir()
);
if (!defined("DRUPAL_CONSOLE_CORE")) {
define(
"DRUPAL_CONSOLE_CORE",
"/{$vendorDir}/drupal/console-core/"
);
}
if (!defined("DRUPAL_CONSOLE")) {
define("DRUPAL_CONSOLE", "/{$vendorDir}/drupal/console/");
}
if (!defined("DRUPAL_CONSOLE_LANGUAGE")) {
define(
"DRUPAL_CONSOLE_LANGUAGE",
"/{$vendorDir}/drupal/console-%s/translations/"
);
}

$this->defineConstants($vendorDir);

return true;
}

$this->defineConstants($vendorDir);
return false;
}

protected function defineConstants($vendorDir) {
if (!defined("DRUPAL_CONSOLE_CORE")) {
define(
"DRUPAL_CONSOLE_CORE",
"/{$vendorDir}/drupal/console-core/"
);
}
if (!defined("DRUPAL_CONSOLE")) {
define("DRUPAL_CONSOLE", "/{$vendorDir}/drupal/console/");
}
if (!defined("DRUPAL_CONSOLE_LANGUAGE")) {
define(
"DRUPAL_CONSOLE_LANGUAGE",
"/{$vendorDir}/drupal/console-%s/translations/"
);
}
}
}

0 comments on commit 0dca9fd

Please sign in to comment.