Skip to content

Commit

Permalink
Update drupal finder add new methods (#177)
Browse files Browse the repository at this point in the history
[console] Add new methods to DrupalFinder.
  • Loading branch information
jmolivas committed Jun 26, 2017
1 parent 2d49bba commit be1ced4
Showing 1 changed file with 56 additions and 4 deletions.
60 changes: 56 additions & 4 deletions src/Utils/DrupalFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Drupal\Console\Core\Utils;

use DrupalFinder\DrupalFinder as DrupalFinderBase;
use Webmozart\PathUtil\Path;

/**
* Class DrupalFinder
Expand All @@ -16,25 +17,52 @@
*/
class DrupalFinder extends DrupalFinderBase
{

/**
* @var string
*/
protected $consoleCorePath;

/**
* @var string
*/
protected $consolePath;

/**
* @var string
*/
protected $consoleLanguagePath;

public function locateRoot($start_path)
{
$vendorDir = 'vendor';
if (parent::locateRoot($start_path)) {
$composerRoot = $this->getComposerRoot();
$vendorDir = str_replace(
$composerRoot .'/', '', $this->getVendorDir()
$vendorDir = Path::makeRelative(
$this->getVendorDir(),
$this->getComposerRoot()
);

$this->definePaths($vendorDir);
$this->defineConstants($vendorDir);

return true;
}

$this->definePaths($vendorDir);
$this->defineConstants($vendorDir);

return false;
}

protected function defineConstants($vendorDir) {
protected function definePaths($vendorDir)
{
$this->consoleCorePath = "/{$vendorDir}/drupal/console-core/";
$this->consolePath = "/{$vendorDir}/drupal/console/";
$this->consoleLanguagePath = "/{$vendorDir}/drupal/console-%s/translations/";
}

protected function defineConstants($vendorDir)
{
if (!defined("DRUPAL_CONSOLE_CORE")) {
define(
"DRUPAL_CONSOLE_CORE",
Expand All @@ -51,4 +79,28 @@ protected function defineConstants($vendorDir) {
);
}
}

/**
* @return string
*/
public function getConsoleCorePath()
{
return $this->consoleCorePath;
}

/**
* @return string
*/
public function getConsolePath()
{
return $this->consolePath;
}

/**
* @return string
*/
public function getConsoleLanguagePath()
{
return $this->consoleLanguagePath;
}
}

0 comments on commit be1ced4

Please sign in to comment.