Changeset 20049
- Timestamp:
- 07/09/09 12:03:04 (4 years ago)
- Files:
-
- branches/1.1/lib/command/sfSymfonyCommandApplication.class.php (modified) (3 diffs)
- branches/1.1/test/other/fixtures/task (added)
- branches/1.1/test/other/fixtures/task/aTask.class.php (added)
- branches/1.1/test/other/fixtures/task/myPluginTask.class.php (added)
- branches/1.1/test/other/fixtures/task/zTask.class.php (added)
- branches/1.1/test/other/tasksTest.php (modified) (2 diffs)
- branches/1.2/lib/command/sfSymfonyCommandApplication.class.php (modified) (3 diffs)
- branches/1.2/test/other/fixtures/task (added)
- branches/1.2/test/other/fixtures/task/aTask.class.php (added)
- branches/1.2/test/other/fixtures/task/myPluginTask.class.php (added)
- branches/1.2/test/other/fixtures/task/zTask.class.php (added)
- branches/1.2/test/other/tasksTest.php (modified) (2 diffs)
- branches/1.3/lib/command/sfSymfonyCommandApplication.class.php (modified) (3 diffs)
- branches/1.3/test/other/fixtures/task (added)
- branches/1.3/test/other/fixtures/task/aTask.class.php (added)
- branches/1.3/test/other/fixtures/task/myPluginTask.class.php (added)
- branches/1.3/test/other/fixtures/task/zTask.class.php (added)
- branches/1.3/test/other/tasksTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/lib/command/sfSymfonyCommandApplication.class.php
r19980 r20049 19 19 class sfSymfonyCommandApplication extends sfCommandApplication 20 20 { 21 protected $taskDirs = array(); 22 21 23 /** 22 24 * Configures the current symfony command application. … … 89 91 { 90 92 // Symfony core tasks 91 $ dirs = array(sfConfig::get('sf_symfony_lib_dir').'/task');93 $this->taskDirs = array(sfConfig::get('sf_symfony_lib_dir').'/task'); 92 94 93 95 // Plugin tasks … … 96 98 if (is_dir($taskPath = $path.'/lib/task')) 97 99 { 98 $ dirs[] = $taskPath;100 $this->taskDirs[] = $taskPath; 99 101 } 100 102 } 101 103 102 104 // project tasks 103 $ dirs[] = sfConfig::get('sf_lib_dir').'/task';105 $this->taskDirs[] = sfConfig::get('sf_lib_dir').'/task'; 104 106 105 107 // require tasks 106 $finder = sfFinder::type('file')->sort_by_name()->name('*Task.class.php'); 107 foreach ($finder->in($dirs) as $task) 108 $finder = sfFinder::type('file')->name('*Task.class.php'); 109 110 // register local autoloader for tasks 111 spl_autoload_register(array($this, 'autoloadTask')); 112 113 foreach ($finder->in($this->taskDirs) as $task) 108 114 { 109 // force autoloading the class 110 if (!class_exists(basename($task, '.class.php'))) 115 // forces autoloading of each task class 116 class_exists(basename($task, '.class.php'), true); 117 } 118 119 // unregister local autoloader 120 spl_autoload_unregister(array($this, 'autoloadTask')); 121 } 122 123 /** 124 * Autoloads a task class 125 * 126 * @param string $class The task class name 127 * 128 * @return Boolean 129 */ 130 public function autoloadTask($class) 131 { 132 foreach ($this->taskDirs as $dir) 133 { 134 if (file_exists($file = $dir.'/'.$class.'.class.php')) 111 135 { 112 require_once $task; 136 require_once $file; 137 138 return true; 113 139 } 114 140 } 141 142 return false; 115 143 } 116 144 branches/1.1/test/other/tasksTest.php
r18746 r20049 65 65 } 66 66 67 $t = new lime_test(3 4, new lime_output_color());67 $t = new lime_test(37, new lime_output_color()); 68 68 69 69 if (!extension_loaded('SQLite')) … … 142 142 $content = $c->execute_command('cache:clear'); 143 143 144 // Test task autoloading 145 mkdir($c->tmp_dir.DS.'lib'.DS.'task'); 146 copy(dirname(__FILE__).'/fixtures/task/aTask.class.php', $c->tmp_dir.DS.'lib'.DS.'task'.DS.'aTask.class.php'); 147 copy(dirname(__FILE__).'/fixtures/task/zTask.class.php', $c->tmp_dir.DS.'lib'.DS.'task'.DS.'zTask.class.php'); 148 mkdir($pluginDir = $c->tmp_dir.DS.'plugins'.DS.'myFooPlugin'.DS.'lib'.DS.'task', 0777, true); 149 copy(dirname(__FILE__).'/fixtures/task/myPluginTask.class.php', $pluginDir.DS.'myPluginTask.class.php'); 150 151 $c->execute_command('a:run'); 152 $c->execute_command('z:run'); 153 $c->execute_command('p:run'); 154 144 155 $c->shutdown(); branches/1.2/lib/command/sfSymfonyCommandApplication.class.php
r19980 r20049 19 19 class sfSymfonyCommandApplication extends sfCommandApplication 20 20 { 21 protected $taskDirs = array(); 22 21 23 /** 22 24 * Configures the current symfony command application. … … 89 91 { 90 92 // Symfony core tasks 91 $ dirs = array(sfConfig::get('sf_symfony_lib_dir').'/task');93 $this->taskDirs = array(sfConfig::get('sf_symfony_lib_dir').'/task'); 92 94 93 95 // Plugin tasks … … 96 98 if (is_dir($taskPath = $path.'/lib/task')) 97 99 { 98 $ dirs[] = $taskPath;100 $this->taskDirs[] = $taskPath; 99 101 } 100 102 } 101 103 102 104 // project tasks 103 $ dirs[] = sfConfig::get('sf_lib_dir').'/task';105 $this->taskDirs[] = sfConfig::get('sf_lib_dir').'/task'; 104 106 105 107 // require tasks 106 $finder = sfFinder::type('file')->sort_by_name()->name('*Task.class.php'); 107 foreach ($finder->in($dirs) as $task) 108 $finder = sfFinder::type('file')->name('*Task.class.php'); 109 110 // register local autoloader for tasks 111 spl_autoload_register(array($this, 'autoloadTask')); 112 113 foreach ($finder->in($this->taskDirs) as $task) 108 114 { 109 // force autoloading the class 110 if (!class_exists(basename($task, '.class.php'))) 115 // forces autoloading of each task class 116 class_exists(basename($task, '.class.php'), true); 117 } 118 119 // unregister local autoloader 120 spl_autoload_unregister(array($this, 'autoloadTask')); 121 } 122 123 /** 124 * Autoloads a task class 125 * 126 * @param string $class The task class name 127 * 128 * @return Boolean 129 */ 130 public function autoloadTask($class) 131 { 132 foreach ($this->taskDirs as $dir) 133 { 134 if (file_exists($file = $dir.'/'.$class.'.class.php')) 111 135 { 112 require_once $task; 136 require_once $file; 137 138 return true; 113 139 } 114 140 } 141 142 return false; 115 143 } 116 144 branches/1.2/test/other/tasksTest.php
r18746 r20049 66 66 } 67 67 68 $t = new lime_test( 37, new lime_output_color());68 $t = new lime_test(40, new lime_output_color()); 69 69 70 70 if (!extension_loaded('SQLite')) … … 148 148 $content = $c->execute_command('cache:clear'); 149 149 150 // Test task autoloading 151 mkdir($c->tmp_dir.DS.'lib'.DS.'task'); 152 copy(dirname(__FILE__).'/fixtures/task/aTask.class.php', $c->tmp_dir.DS.'lib'.DS.'task'.DS.'aTask.class.php'); 153 copy(dirname(__FILE__).'/fixtures/task/zTask.class.php', $c->tmp_dir.DS.'lib'.DS.'task'.DS.'zTask.class.php'); 154 mkdir($pluginDir = $c->tmp_dir.DS.'plugins'.DS.'myFooPlugin'.DS.'lib'.DS.'task', 0777, true); 155 copy(dirname(__FILE__).'/fixtures/task/myPluginTask.class.php', $pluginDir.DS.'myPluginTask.class.php'); 156 157 $c->execute_command('a:run'); 158 $c->execute_command('z:run'); 159 $c->execute_command('p:run'); 160 150 161 $c->shutdown(); branches/1.3/lib/command/sfSymfonyCommandApplication.class.php
r19980 r20049 19 19 class sfSymfonyCommandApplication extends sfCommandApplication 20 20 { 21 protected $taskDirs = array(); 22 21 23 /** 22 24 * Configures the current symfony command application. … … 89 91 { 90 92 // Symfony core tasks 91 $ dirs = array(sfConfig::get('sf_symfony_lib_dir').'/task');93 $this->taskDirs = array(sfConfig::get('sf_symfony_lib_dir').'/task'); 92 94 93 95 // Plugin tasks … … 96 98 if (is_dir($taskPath = $path.'/lib/task')) 97 99 { 98 $ dirs[] = $taskPath;100 $this->taskDirs[] = $taskPath; 99 101 } 100 102 } 101 103 102 104 // project tasks 103 $ dirs[] = sfConfig::get('sf_lib_dir').'/task';105 $this->taskDirs[] = sfConfig::get('sf_lib_dir').'/task'; 104 106 105 107 // require tasks 106 $finder = sfFinder::type('file')->sort_by_name()->name('*Task.class.php'); 107 foreach ($finder->in($dirs) as $task) 108 $finder = sfFinder::type('file')->name('*Task.class.php'); 109 110 // register local autoloader for tasks 111 spl_autoload_register(array($this, 'autoloadTask')); 112 113 foreach ($finder->in($this->taskDirs) as $task) 108 114 { 109 // force autoloading the class 110 if (!class_exists(basename($task, '.class.php'))) 115 // forces autoloading of each task class 116 class_exists(basename($task, '.class.php'), true); 117 } 118 119 // unregister local autoloader 120 spl_autoload_unregister(array($this, 'autoloadTask')); 121 } 122 123 /** 124 * Autoloads a task class 125 * 126 * @param string $class The task class name 127 * 128 * @return Boolean 129 */ 130 public function autoloadTask($class) 131 { 132 foreach ($this->taskDirs as $dir) 133 { 134 if (file_exists($file = $dir.'/'.$class.'.class.php')) 111 135 { 112 require_once $task; 136 require_once $file; 137 138 return true; 113 139 } 114 140 } 141 142 return false; 115 143 } 116 144 branches/1.3/test/other/tasksTest.php
r19531 r20049 66 66 } 67 67 68 $t = new lime_test(3 5);68 $t = new lime_test(38); 69 69 70 70 if (!extension_loaded('SQLite')) … … 144 144 $content = $c->execute_command('cache:clear'); 145 145 146 // Test task autoloading 147 mkdir($c->tmp_dir.DS.'lib'.DS.'task'); 148 copy(dirname(__FILE__).'/fixtures/task/aTask.class.php', $c->tmp_dir.DS.'lib'.DS.'task'.DS.'aTask.class.php'); 149 copy(dirname(__FILE__).'/fixtures/task/zTask.class.php', $c->tmp_dir.DS.'lib'.DS.'task'.DS.'zTask.class.php'); 150 mkdir($pluginDir = $c->tmp_dir.DS.'plugins'.DS.'myFooPlugin'.DS.'lib'.DS.'task', 0777, true); 151 copy(dirname(__FILE__).'/fixtures/task/myPluginTask.class.php', $pluginDir.DS.'myPluginTask.class.php'); 152 file_put_contents( 153 $projectConfigurationFile = $c->tmp_dir.DS.'config'.DS.'ProjectConfiguration.class.php', 154 str_replace( 155 '$this->enablePlugins(\'sfPropelPlugin\')', 156 '$this->enablePlugins(array(\'myFooPlugin\', \'sfPropelPlugin\'))', 157 file_get_contents($projectConfigurationFile) 158 ) 159 ); 160 161 $c->execute_command('a:run'); 162 $c->execute_command('z:run'); 163 $c->execute_command('p:run'); 164 146 165 $c->shutdown();