3333; ; Return root directory of current buffer file. The root directory is
3434; ; determined by several marker file or directory.
3535; ;
36+ ; ; ### `php-project-get-bootstrap-scripts()'
37+ ; ;
38+ ; ; Return list of path to bootstrap script file.
39+ ; ;
3640; ; ## `.dir-locals.el' support
3741; ;
3842; ; - `php-project-coding-style'
3943; ; - Symbol value of the coding style. (ex. `pear' , `psr2' )
4044; ; - `php-project-root'
4145; ; - Symbol of marker file of project root. (ex. `git' , `composer' )
4246; ; - Full path to project root directory. (ex. "/path/to/your-project")
47+ ; ; - `php-project-bootstrap-scripts'
48+ ; ; - List of path to bootstrap file of project.
49+ ; ; (ex. (((root . "vendor/autoload.php") (root . "inc/bootstrap.php")))
4350; ;
4451
4552; ;; Code:
@@ -73,6 +80,16 @@ SYMBOL
7380 (put 'php-project-root 'safe-local-variable
7481 #' (lambda (v ) (assq v php-project-available-root-files))))
7582
83+ ;;;### autoload
84+ (progn
85+ (defvar php-project-bootstrap-scripts nil
86+ " List of path to bootstrap php script file.
87+
88+ The ideal bootstrap file is silent, it only includes dependent files,
89+ defines constants, and sets the class loaders." )
90+ (make-variable-buffer-local 'php-project-bootstrap-scripts )
91+ (put 'php-project-bootstrap-scripts 'safe-local-variable #'php-project--eval-bootstrap-scripts ))
92+
7693;;;### autoload
7794(progn
7895 (defvar php-project-coding-style nil
@@ -85,6 +102,24 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.")
85102
86103; ; Functions
87104
105+ (defun php-project--eval-bootstrap-scripts (val )
106+ " Return T when `VAL' is valid list of safe bootstrap php script."
107+ (cond
108+ ((stringp val) (and (file-exists-p val) val))
109+ ((and (consp val) (eq 'root (car val)) (stringp (cdr val)))
110+ (let ((path (expand-file-name (cdr val) (php-project-get-root-dir))))
111+ (and (file-exists-p path) path)))
112+ ((null val) nil )
113+ ((listp val)
114+ (cl-loop for v in val collect (php-project--eval-bootstrap-scripts v)))
115+ (t nil )))
116+
117+ ;;;### autoload
118+ (defun php-project-get-bootstrap-scripts ()
119+ " Return list of bootstrap script."
120+ (let ((scripts (php-project--eval-bootstrap-scripts php-project-bootstrap-scripts)))
121+ (if (stringp scripts) (list scripts) scripts)))
122+
88123;;;### autoload
89124(defun php-project-get-root-dir ()
90125 " Return path to current PHP project."
0 commit comments