Skip to content

Commit 115aa5f

Browse files
committed
Impl interop to Projectile
Add `php-project-use-projectile-to-detect-root` custom variable.
1 parent 167b357 commit 115aa5f

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Cask

+1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99

1010
(development
1111
(depends-on "pkg-info")
12+
(depends-on "projectile")
1213
(depends-on "shut-up"))

php-project.el

+15
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868

6969
;;; Code:
7070
(require 'cl-lib)
71+
(require 'projectile nil t)
7172

7273
;; Constants
7374
(defconst php-project-composer-autoloader "vendor/autoload.php")
@@ -84,6 +85,12 @@
8485
:tag "PHP Project Auto Detect Etags File"
8586
:group 'php-project
8687
:type 'boolean)
88+
89+
(defcustom php-project-use-projectile-to-detect-root nil
90+
"If `T' and projectile-mode is activated, use Projectile for root detection."
91+
:tag "PHP Project Use Projectile To Detect Root"
92+
:group 'php-project
93+
:type 'boolean)
8794

8895
;; Variables
8996
(defvar php-project-available-root-files
@@ -269,6 +276,14 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.")
269276
"Return path to current PHP project."
270277
(if (and (stringp php-project-root) (file-directory-p php-project-root))
271278
php-project-root
279+
(php-project--detect-root-dir)))
280+
281+
(defun php-project--detect-root-dir ()
282+
"Return detected project root."
283+
(if (and php-project-use-projectile-to-detect-root
284+
(bound-and-true-p projectile-mode)
285+
(fboundp 'projectile-project-root))
286+
(projectile-project-root default-directory)
272287
(let ((detect-method
273288
(cond
274289
((stringp php-project-root) (list php-project-root))

0 commit comments

Comments
 (0)