Skip to content

Commit

Permalink
Allow user to specify the path to the php executable
Browse files Browse the repository at this point in the history
  • Loading branch information
karptonite committed Jul 9, 2013
1 parent 8a20f0b commit 179a20b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
34 changes: 34 additions & 0 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"caption": "Preferences",
"mnemonic": "n",
"id": "preferences",
"children":
[
{
"caption": "Package Settings",
"mnemonic": "P",
"id": "package-settings",
"children":
[
{
"caption": "PHP Refactor",
"children":
[
{
"command": "open_file",
"args": {"file": "${packages}/sublime-text-2-php-refactor/sublime-text-2-php-refactor.sublime-settings"},
"caption": "Settings – Default"
},
{
"command": "open_file",
"args": {"file": "${packages}/User/sublime-text-2-php-refactor.sublime-settings"},
"caption": "Settings – User"
}
]
}
]
}
]
}
]
7 changes: 4 additions & 3 deletions sublime-text-2-php-refactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def load():
msg("Backup file before applying changes? %s" % Prefs.backup)
Prefs.confirm = settings.get('confirm')
msg("Confirm action before applying changes? %s" % Prefs.confirm)
Prefs.path_to_php = settings.get('path_to_php') if settings.get('path_to_php') else 'php'


Prefs.load()
Expand Down Expand Up @@ -125,7 +126,7 @@ def run(self, edit, execute=False):
def runCommandLine(self, filePath, fromLine, toLine, newFcName, execute=False):
patch = self.patch(execute, filePath)

command = "php " + self.REFACTOR + " extract-method " + filePath + " " + fromLine + "-" + toLine + " " + newFcName + patch
command = Prefs.path_to_php + " " + self.REFACTOR + " extract-method " + filePath + " " + fromLine + "-" + toLine + " " + newFcName + patch

if ((True == execute) and (True == Prefs.confirm)):
self.confirm(lambda x: self.execute('extract_' + newFcName, command, execute))
Expand Down Expand Up @@ -155,7 +156,7 @@ def run(self, edit, execute=False):
def runCommandLine(self, filePath, line, oldVarName, newVarName, execute=False):
patch = self.patch(execute, filePath)

command = "php " + self.REFACTOR + " rename-local-variable " + filePath + " " + line + " " + oldVarName + " " + newVarName + patch
command = Prefs.path_to_php + " " + self.REFACTOR + " rename-local-variable " + filePath + " " + line + " " + oldVarName + " " + newVarName + patch

if ((True == execute) and (True == Prefs.confirm)):
self.confirm(lambda x: self.execute('rename-local-var_' + oldVarName + newVarName, command, execute))
Expand Down Expand Up @@ -192,7 +193,7 @@ def run(self, edit, execute=False):
def runCommandLine(self, filePath, line, varName, execute=False):
patch = self.patch(execute, filePath)

command = "php " + self.REFACTOR + " convert-local-to-instance-variable " + filePath + " " + line + " " + varName + patch
command = Prefs.path_to_php + " " + self.REFACTOR + " convert-local-to-instance-variable " + filePath + " " + line + " " + varName + patch

if ((True == execute) and (True == Prefs.confirm)):
self.confirm(lambda x: self.execute('local-var-to-instance_' + varName, command, execute))
Expand Down

0 comments on commit 179a20b

Please sign in to comment.