Skip to content

Commit ec3fcca

Browse files
committed
adding getPathPHP and getPathConsole for plugins to hook into for processes
1 parent 7ed9aa1 commit ec3fcca

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/PatternLab/Console.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,42 @@ public static function getCommand() {
163163
return false;
164164
}
165165

166+
/**
167+
* Get the path to PHP binary
168+
*
169+
* @return {String} the path to the PHP executable
170+
*/
171+
public static function getPathPHP() {
172+
173+
$path = isset($_SERVER["_"]) ? $_SERVER["_"] : Config::getOption("phpBin");
174+
175+
if (!$path) {
176+
$configPath = Console::getHumanReadablePath(Config::getOption("configPath"));
177+
Console::writeError("please add the option `phpBin` with the path to PHP to <path>".$configPath."</path> to run this process...");
178+
}
179+
180+
return $path;
181+
182+
}
183+
184+
/**
185+
* Get the path to the calling script. Should be core/console but let's not make that assumption
186+
*
187+
* @return {String} the path to the calling script
188+
*/
189+
public static function getPathConsole() {
190+
191+
$console = isset($_SERVER["SCRIPT_NAME"]) ? $_SERVER["SCRIPT_NAME"] : Config::getOption("phpScriptName");
192+
193+
if (!$console) {
194+
$configPath = Console::getHumanReadablePath(Config::getOption("configPath"));
195+
Console::writeError("please add the option `phpScriptName` with the path to your console option (e.g. core/console) to <path>".$configPath."</path> to run this process...");
196+
}
197+
198+
return Config::getOption("baseDir").$console;
199+
200+
}
201+
166202
/**
167203
* Load all of the rules related to Pattern Data
168204
*/

0 commit comments

Comments
 (0)