3
3
4
4
use Consolidation \SiteProcess \Util \Shell ;
5
5
use Drush \Drush ;
6
- use Drush \Log \LogLevel ;
7
6
8
7
trait ExecTrait
9
8
{
@@ -14,13 +13,16 @@ trait ExecTrait
14
13
*
15
14
* @param $uri
16
15
* Optional URI or site path to open in browser. If omitted, or if a site path
17
- * is specified, the current site home page uri will be prepended if the sites
16
+ * is specified, the current site home page uri will be prepended if the site's
18
17
* hostname resolves.
19
- * @return
18
+ * @param int $sleep
19
+ * @param bool $port
20
+ * @param bool $browser
21
+ * @return bool TRUE if browser was opened, FALSE if browser was disabled by the user or a,
20
22
* TRUE if browser was opened, FALSE if browser was disabled by the user or a,
21
23
* default browser could not be found.
22
24
*/
23
- public function startBrowser ($ uri = null , $ sleep = false , $ port = false , $ browser = true )
25
+ public function startBrowser ($ uri = null , $ sleep = 0 , $ port = false , $ browser = true )
24
26
{
25
27
if ($ browser ) {
26
28
// We can only open a browser if we have a DISPLAY environment variable on
@@ -32,7 +34,7 @@ public function startBrowser($uri = null, $sleep = false, $port = false, $browse
32
34
$ host = parse_url ($ uri , PHP_URL_HOST );
33
35
if (!$ host ) {
34
36
// Build a URI for the current site, if we were passed a path.
35
- $ site = drush_get_context ( ' DRUSH_URI ' ) ;
37
+ $ site = $ this -> uri ;
36
38
$ host = parse_url ($ site , PHP_URL_HOST );
37
39
$ uri = $ site . '/ ' . ltrim ($ uri , '/ ' );
38
40
}
@@ -49,9 +51,9 @@ public function startBrowser($uri = null, $sleep = false, $port = false, $browse
49
51
}
50
52
if ($ browser === true ) {
51
53
// See if we can find an OS helper to open URLs in default browser.
52
- if (drush_which ('xdg-open ' )) {
54
+ if (self :: programExists ('xdg-open ' )) {
53
55
$ browser = 'xdg-open ' ;
54
- } else if (drush_which ('open ' )) {
56
+ } else if (self :: programExists ('open ' )) {
55
57
$ browser = 'open ' ;
56
58
} else if (!drush_has_bash ()) {
57
59
$ browser = 'start ' ;
0 commit comments