From 688d58f51120786b099509ea3785a8057ae36265 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Thu, 2 Aug 2012 21:49:31 +0000 Subject: Implémentation pour Cake : étape 1 sur 124684 réalisée : Fonction detectFramework() implementée. Parse le app/webroot/index.php pour récurérer tous les define() et les évalue statiquement et ça marche ! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///var/svn/2012-php-weave/trunk@10 d972a294-176a-4cf9-8ea1-fcd5b0c30f5c --- .../src/php-weave/cakephp_weaver.class.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'poc/poc02-compiling-cake/src/php-weave/cakephp_weaver.class.php') diff --git a/poc/poc02-compiling-cake/src/php-weave/cakephp_weaver.class.php b/poc/poc02-compiling-cake/src/php-weave/cakephp_weaver.class.php index cc25641..508e509 100644 --- a/poc/poc02-compiling-cake/src/php-weave/cakephp_weaver.class.php +++ b/poc/poc02-compiling-cake/src/php-weave/cakephp_weaver.class.php @@ -3,7 +3,23 @@ require_once 'abstract_weaver.class.php'; class CakePHPWeaver extends AbstractWeaver { public function detectFramework($sourcetree_rootpath) { + //FIXME : there is other cases to cover + $entrypoint_path=$sourcetree_rootpath.'/app/webroot/index.php'; + assert('is_readable($entrypoint_path)'); + $entrypoint_ast=$this->parseAndWalk($entrypoint_path, null); + //echo $this->nodeDumper->dump($entrypoint_ast); + + $magics=array('__FILE__' => $entrypoint_path); + $fw_props=$this->staticEvalDefine($entrypoint_ast, $magics); + if (!is_array($fw_props)) throw new Exception("No properties found in '$entrypoint_path'"); + + print_r($fw_props); + $required=array('ROOT','APP_DIR','CAKE_CORE_INCLUDE_PATH','WEBROOT_DIR', 'WWW_ROOT'); + $missing=array_diff($required, array_keys($fw_props)); + print_r($missing); + assert('count($missing)===0;'); + return array_merge(array('entrypoint_path' => $entrypoint_path), $fw_props); } public function parseFrameworkConfig($fw_props) { -- cgit v1.2.3