[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 3 /* 4 * This file is part of the symfony package. 5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 6 * 7 * For the full copyright and license information, please view the LICENSE 8 * file that was distributed with this source code. 9 */ 10 11 if (!isset($sf_symfony_lib_dir)) 12 { 13 die("You must launch symfony command line with the symfony script\n"); 14 } 15 16 if (ini_get('zend.ze1_compatibility_mode')) 17 { 18 die("symfony cannot run with zend.ze1_compatibility_mode enabled.\nPlease turn zend.ze1_compatibility_mode to Off in your php.ini.\n"); 19 } 20 21 // check if we are using an old project 22 if (file_exists('config/config.php') && !isset($sf_symfony_lib_dir)) 23 { 24 // allow only upgrading 25 if (!in_array('upgrade', $argv)) 26 { 27 echo "Please upgrade your project before launching any other symfony task\n"; 28 exit(); 29 } 30 } 31 32 require_once($sf_symfony_lib_dir.'/vendor/pake/pakeFunction.php'); 33 require_once($sf_symfony_lib_dir.'/vendor/pake/pakeGetopt.class.php'); 34 35 // autoloading for pake tasks 36 class simpleAutoloader 37 { 38 static public 39 $class_paths = array(), 40 $autoload_callables = array(); 41 42 static public function initialize($sf_symfony_lib_dir) 43 { 44 self::$class_paths = array(); 45 46 self::register($sf_symfony_lib_dir, '.class.php'); 47 self::register($sf_symfony_lib_dir.'/vendor/propel', '.php'); 48 self::register($sf_symfony_lib_dir.'/vendor/creole', '.php'); 49 self::register('lib/model', '.php'); 50 self::register('plugins', '.php'); 51 } 52 53 static public function __autoload($class) 54 { 55 if (!isset(self::$class_paths[$class])) 56 { 57 foreach ((array) self::$autoload_callables as $callable) 58 { 59 if (call_user_func($callable, $class)) 60 { 61 return true; 62 } 63 } 64 65 return false; 66 } 67 68 require_once(self::$class_paths[$class]); 69 70 return true; 71 } 72 73 static public function register($dir, $ext) 74 { 75 if (!is_dir($dir)) 76 { 77 return; 78 } 79 80 foreach (pakeFinder::type('file')->name('*'.$ext)->ignore_version_control()->follow_link()->in($dir) as $file) 81 { 82 self::$class_paths[str_replace($ext, '', str_replace('.class', '', basename($file, $ext)))] = $file; 83 } 84 } 85 86 static public function add($class, $file) 87 { 88 if (!is_file($file)) 89 { 90 return; 91 } 92 93 self::$class_paths[$class] = $file; 94 } 95 96 static public function registerCallable($callable) 97 { 98 if (!is_callable($callable)) 99 { 100 throw new Exception('Autoload callable does not exist'); 101 } 102 103 self::$autoload_callables[] = $callable; 104 } 105 } 106 107 function __autoload($class) 108 { 109 static $initialized = false; 110 111 if (!$initialized) 112 { 113 simpleAutoloader::initialize(sfConfig::get('sf_symfony_lib_dir')); 114 $initialized = true; 115 } 116 117 return simpleAutoloader::__autoload($class); 118 } 119 120 // trap -V before pake 121 if (in_array('-V', $argv) || in_array('--version', $argv)) 122 { 123 printf("symfony version %s\n", pakeColor::colorize(trim(file_get_contents($sf_symfony_lib_dir.'/VERSION')), 'INFO')); 124 exit(0); 125 } 126 127 if (count($argv) <= 1) 128 { 129 $argv[] = '-T'; 130 } 131 132 require_once($sf_symfony_lib_dir.'/config/sfConfig.class.php'); 133 134 sfConfig::add(array( 135 'sf_root_dir' => getcwd(), 136 'sf_symfony_lib_dir' => $sf_symfony_lib_dir, 137 'sf_symfony_data_dir' => $sf_symfony_data_dir, 138 )); 139 140 // directory layout 141 include($sf_symfony_data_dir.'/config/constants.php'); 142 143 // include path 144 set_include_path( 145 sfConfig::get('sf_lib_dir').PATH_SEPARATOR. 146 sfConfig::get('sf_app_lib_dir').PATH_SEPARATOR. 147 sfConfig::get('sf_model_dir').PATH_SEPARATOR. 148 sfConfig::get('sf_symfony_lib_dir').DIRECTORY_SEPARATOR.'vendor'.PATH_SEPARATOR. 149 get_include_path() 150 ); 151 152 // register tasks 153 $dirs = array( 154 sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'tasks' => 'myPake*.php', // project tasks 155 sfConfig::get('sf_symfony_data_dir').DIRECTORY_SEPARATOR.'tasks' => 'sfPake*.php', // symfony tasks 156 sfConfig::get('sf_root_dir').'/plugins/*/data/tasks' => '*.php', // plugin tasks 157 ); 158 foreach ($dirs as $globDir => $name) 159 { 160 if ($dirs = glob($globDir)) 161 { 162 $tasks = pakeFinder::type('file')->name($name)->in($dirs); 163 foreach ($tasks as $task) 164 { 165 include_once($task); 166 } 167 } 168 } 169 170 // run task 171 pakeApp::get_instance()->run(null, null, false); 172 173 exit(0);
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |