Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}