X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fdrupal%2Fconsole-core%2Fsrc%2FUtils%2FDrupalFinder.php;fp=vendor%2Fdrupal%2Fconsole-core%2Fsrc%2FUtils%2FDrupalFinder.php;h=2aa7af27c8a419f352613d4c06f67702bd8907f5;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=1619bf9cf08f20cc5aac97ea2c9eb9ddcbd346c0;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/vendor/drupal/console-core/src/Utils/DrupalFinder.php b/vendor/drupal/console-core/src/Utils/DrupalFinder.php index 1619bf9cf..2aa7af27c 100644 --- a/vendor/drupal/console-core/src/Utils/DrupalFinder.php +++ b/vendor/drupal/console-core/src/Utils/DrupalFinder.php @@ -8,6 +8,7 @@ namespace Drupal\Console\Core\Utils; use DrupalFinder\DrupalFinder as DrupalFinderBase; +use Webmozart\PathUtil\Path; /** * Class DrupalFinder @@ -16,32 +17,101 @@ use DrupalFinder\DrupalFinder as DrupalFinderBase; */ 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() ); - 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->definePaths($vendorDir); + $this->defineConstants($vendorDir); return true; } + $this->definePaths($vendorDir); + $this->defineConstants($vendorDir); + return false; } + + 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", + "/{$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/" + ); + } + + if (!defined("DRUPAL_CONSOLE_LIBRARY")) { + define( + "DRUPAL_CONSOLE_LIBRARY", + "/{$vendorDir}/drupal/%s/console/translations/%s" + ); + } + } + + /** + * @return string + */ + public function getConsoleCorePath() + { + return $this->consoleCorePath; + } + + /** + * @return string + */ + public function getConsolePath() + { + return $this->consolePath; + } + + /** + * @return string + */ + public function getConsoleLanguagePath() + { + return $this->consoleLanguagePath; + } + + public function isValidDrupal() { + return ($this->getComposerRoot() && $this->getDrupalRoot()); + } }