Skip to content

Commit

Permalink
Impl interop to Projectile
Browse files Browse the repository at this point in the history
Add `php-project-use-projectile-to-detect-root` custom variable.
  • Loading branch information
zonuexe committed Jan 21, 2020
1 parent 167b357 commit 115aa5f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cask
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@

(development
(depends-on "pkg-info")
(depends-on "projectile")
(depends-on "shut-up"))
15 changes: 15 additions & 0 deletions php-project.el
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@

;;; Code:
(require 'cl-lib)
(require 'projectile nil t)

;; Constants
(defconst php-project-composer-autoloader "vendor/autoload.php")
Expand All @@ -84,6 +85,12 @@
:tag "PHP Project Auto Detect Etags File"
:group 'php-project
:type 'boolean)

(defcustom php-project-use-projectile-to-detect-root nil
"If `T' and projectile-mode is activated, use Projectile for root detection."
:tag "PHP Project Use Projectile To Detect Root"
:group 'php-project
:type 'boolean)

;; Variables
(defvar php-project-available-root-files
Expand Down Expand Up @@ -269,6 +276,14 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.")
"Return path to current PHP project."
(if (and (stringp php-project-root) (file-directory-p php-project-root))
php-project-root
(php-project--detect-root-dir)))

(defun php-project--detect-root-dir ()
"Return detected project root."
(if (and php-project-use-projectile-to-detect-root
(bound-and-true-p projectile-mode)
(fboundp 'projectile-project-root))
(projectile-project-root default-directory)
(let ((detect-method
(cond
((stringp php-project-root) (list php-project-root))
Expand Down

0 comments on commit 115aa5f

Please sign in to comment.