Changeset 5250
- Timestamp:
- 09/24/07 10:11:50 (2 years ago)
- Files:
-
- trunk/data/bin/symfony.php (modified) (1 diff)
- trunk/lib/command/sfAnsiColorFormatter.class.php (modified) (1 diff)
- trunk/lib/command/sfCommandLogger.class.php (modified) (1 diff)
- trunk/lib/command/sfFormatter.class.php (modified) (1 diff)
- trunk/lib/plugin (added)
- trunk/lib/plugin/sfPearDownloader.class.php (added)
- trunk/lib/plugin/sfPearEnvironment.class.php (added)
- trunk/lib/plugin/sfPearFrontendPlugin.class.php (added)
- trunk/lib/plugin/sfPearRest.class.php (added)
- trunk/lib/plugin/sfPearRest10.class.php (added)
- trunk/lib/plugin/sfPearRest11.class.php (added)
- trunk/lib/plugin/sfPearRestPlugin.class.php (added)
- trunk/lib/plugin/sfPluginDependencyException.class.php (added)
- trunk/lib/plugin/sfPluginException.class.php (added)
- trunk/lib/plugin/sfPluginManager.class.php (added)
- trunk/lib/plugin/sfPluginRecursiveDependencyException.class.php (added)
- trunk/lib/plugin/sfPluginRestException.class.php (added)
- trunk/lib/plugin/sfSymfonyPluginManager.class.php (added)
- trunk/lib/task/help/sfHelpTask.class.php (modified) (3 diffs)
- trunk/lib/task/help/sfListTask.class.php (modified) (2 diffs)
- trunk/lib/task/plugin/sfPluginAddChannelTask.class.php (added)
- trunk/lib/task/plugin/sfPluginBaseTask.class.php (modified) (2 diffs)
- trunk/lib/task/plugin/sfPluginInstallTask.class.php (modified) (3 diffs)
- trunk/lib/task/plugin/sfPluginListTask.class.php (modified) (1 diff)
- trunk/lib/task/plugin/sfPluginUninstallTask.class.php (modified) (3 diffs)
- trunk/lib/task/plugin/sfPluginUpgradeTask.class.php (modified) (3 diffs)
- trunk/lib/task/sfFilesystem.class.php (modified) (1 diff)
- trunk/test/unit/plugin (added)
- trunk/test/unit/plugin/fixtures (added)
- trunk/test/unit/plugin/fixtures/http (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/p (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/p/sffooplugin (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/p/sffooplugin/info.xml (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/p/sftestplugin (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/p/sftestplugin/info.xml (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/r (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/r/sffooplugin (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/r/sffooplugin/1.0.0.xml (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/r/sffooplugin/allreleases.xml (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/r/sffooplugin/deps.1.0.0.txt (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/r/sftestplugin (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/r/sftestplugin/1.0.0.xml (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/r/sftestplugin/1.0.3.xml (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/r/sftestplugin/1.0.4.xml (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/r/sftestplugin/1.1.3.xml (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/r/sftestplugin/1.1.4.xml (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/r/sftestplugin/allreleases.xml (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/r/sftestplugin/deps.1.0.0.txt (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/r/sftestplugin/deps.1.0.3.txt (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/r/sftestplugin/deps.1.0.4.txt (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/r/sftestplugin/deps.1.1.3.txt (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/REST/r/sftestplugin/deps.1.1.4.txt (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/channel.xml (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/get (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/get/sfFooPlugin (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/get/sfFooPlugin/sfFooPlugin-1.0.0.tgz (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/get/sfTestPlugin (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/get/sfTestPlugin/sfTestPlugin-1.0.0.tgz (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/get/sfTestPlugin/sfTestPlugin-1.0.3.tgz (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/get/sfTestPlugin/sfTestPlugin-1.0.4.tgz (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/get/sfTestPlugin/sfTestPlugin-1.1.3.tgz (added)
- trunk/test/unit/plugin/fixtures/http/pear.example.com/get/sfTestPlugin/sfTestPlugin-1.1.4.tgz (added)
- trunk/test/unit/plugin/fixtures/sfFooPlugin (added)
- trunk/test/unit/plugin/fixtures/sfFooPlugin/package.xml (added)
- trunk/test/unit/plugin/fixtures/sfFooPlugin/sfFooPlugin-1.0.0 (added)
- trunk/test/unit/plugin/fixtures/sfFooPlugin/sfFooPlugin-1.0.0/VERSION (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.0.0 (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.0.0/package.xml (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.0.0/sfTestPlugin-1.0.0 (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.0.0/sfTestPlugin-1.0.0/VERSION (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.0.3 (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.0.3/package.xml (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.0.3/sfTestPlugin-1.0.3 (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.0.3/sfTestPlugin-1.0.3/VERSION (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.0.4 (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.0.4/package.xml (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.0.4/sfTestPlugin-1.0.4 (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.0.4/sfTestPlugin-1.0.4/VERSION (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.1.3 (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.1.3/package.xml (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.1.3/sfTestPlugin-1.1.3 (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.1.3/sfTestPlugin-1.1.3/VERSION (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.1.4 (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.1.4/package.xml (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.1.4/sfTestPlugin-1.1.4 (added)
- trunk/test/unit/plugin/fixtures/sfTestPlugin/sfTestPlugin-1.1.4/sfTestPlugin-1.1.4/VERSION (added)
- trunk/test/unit/plugin/sfPearDownloaderTest.class.php (added)
- trunk/test/unit/plugin/sfPearEnvironmentTest.php (added)
- trunk/test/unit/plugin/sfPearRestPluginTest.php (added)
- trunk/test/unit/plugin/sfPearRestTest.class.php (added)
- trunk/test/unit/plugin/sfPluginManagerTest.php (added)
- trunk/test/unit/plugin/sfPluginTestHelper.class.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/data/bin/symfony.php
r5232 r5250 30 30 $logger = new sfCommandLogger($dispatcher); 31 31 32 $application = new sfSymfonyCommandApplication($dispatcher, new sfAnsiColorFormatter(), array('symfony_lib_dir' => $sf_symfony_lib_dir, 'symfony_data_dir' => $sf_symfony_data_dir)); 32 $options = array( 33 'symfony_lib_dir' => $sf_symfony_lib_dir, 34 'symfony_data_dir' => $sf_symfony_data_dir, 35 ); 36 37 $application = new sfSymfonyCommandApplication($dispatcher, new sfAnsiColorFormatter(), $options); 33 38 $application->run(); 34 39 } 35 40 catch (Exception $e) 36 41 { 42 if (!isset($application)) 43 { 44 throw $e; 45 } 46 37 47 $application->renderException($e); 48 38 49 exit(1); 39 50 } trunk/lib/command/sfAnsiColorFormatter.class.php
r5232 r5250 96 96 $width = 9 + strlen($this->format('', 'INFO')); 97 97 98 return sprintf(">> %-${width}s %s \n", $this->format($section, 'INFO'), $this->excerpt($text, $size));98 return sprintf(">> %-${width}s %s", $this->format($section, 'INFO'), $this->excerpt($text, $size)); 99 99 } 100 100 trunk/lib/command/sfCommandLogger.class.php
r5232 r5250 40 40 { 41 41 $priority = $event->getParameterHolder()->remove('priority', self::INFO); 42 43 $prefix = ''; 44 if ('application.log' == $event->getName()) 45 { 46 $subject = $event->getSubject(); 47 $subject = is_object($subject) ? get_class($subject) : (is_string($subject) ? $subject : 'main'); 48 49 $prefix = '>> '.$subject.' '; 50 } 51 42 52 foreach ($event->getParameterHolder()->getAll() as $message) 43 53 { 44 $this->log(sprintf('%s ', $message), $priority);54 $this->log(sprintf('%s%s', $prefix, $message), $priority); 45 55 } 46 56 } trunk/lib/command/sfFormatter.class.php
r5232 r5250 50 50 public function formatSection($section, $text, $size = null) 51 51 { 52 $width = 9; 53 54 return sprintf(">> %-${width}s %s\n", $section, $this->excerpt($text, $size)); 52 return sprintf(">> %-$9s %s", $section, $this->excerpt($text, $size)); 55 53 } 56 54 trunk/lib/task/help/sfHelpTask.class.php
r5232 r5250 47 47 $messages = array(); 48 48 49 $messages[] = $this->formatter->format( "Usage:\n", 'COMMENT');50 $messages[] = $this->formatter->format(sprintf(' '.$task->getSynopsis(), is_null($this->commandApplication) ? '' : $this->commandApplication->getName()))."\n \n";49 $messages[] = $this->formatter->format('Usage:', 'COMMENT'); 50 $messages[] = $this->formatter->format(sprintf(' '.$task->getSynopsis(), is_null($this->commandApplication) ? '' : $this->commandApplication->getName()))."\n"; 51 51 52 52 // find the largest option or argument name … … 64 64 if ($task->getAliases()) 65 65 { 66 $messages[] = $this->formatter->format( "Aliases:\n", 'COMMENT').' '.$this->formatter->format(implode(', ', $task->getAliases()), 'INFO')."\n\n";66 $messages[] = $this->formatter->format('Aliases:', 'COMMENT').' '.$this->formatter->format(implode(', ', $task->getAliases()), 'INFO')."\n"; 67 67 } 68 68 69 69 if ($task->getArguments()) 70 70 { 71 $messages[] = $this->formatter->format( "Arguments:\n", 'COMMENT');71 $messages[] = $this->formatter->format('Arguments:', 'COMMENT'); 72 72 foreach ($task->getArguments() as $argument) 73 73 { 74 74 $default = !is_null($argument->getDefault()) && (!is_array($argument->getDefault()) || count($argument->getDefault())) ? $this->formatter->format(sprintf(' (default: %s)', is_array($argument->getDefault()) ? str_replace("\n", '', print_r($argument->getDefault(), true)): $argument->getDefault()), 'COMMENT') : ''; 75 $messages[] = sprintf(" %-${max}s %s%s \n", $this->formatter->format($argument->getName(), 'INFO'), $argument->getHelp(), $default);75 $messages[] = sprintf(" %-${max}s %s%s", $this->formatter->format($argument->getName(), 'INFO'), $argument->getHelp(), $default); 76 76 } 77 77 78 $messages[] = "\n";78 $messages[] = ''; 79 79 } 80 80 81 81 if ($task->getOptions()) 82 82 { 83 $messages[] = $this->formatter->format( "Options:\n", 'COMMENT');83 $messages[] = $this->formatter->format('Options:', 'COMMENT'); 84 84 85 85 foreach ($task->getOptions() as $option) … … 87 87 $default = $option->acceptParameter() && !is_null($option->getDefault()) && (!is_array($option->getDefault()) || count($option->getDefault())) ? $this->formatter->format(sprintf(' (default: %s)', is_array($option->getDefault()) ? str_replace("\n", '', print_r($option->getDefault(), true)): $option->getDefault()), 'COMMENT') : ''; 88 88 $multiple = $option->isArray() ? $this->formatter->format(' (multiple values allowed)', 'COMMENT') : ''; 89 $messages[] = sprintf(' %-'.$max.'s %s%s%s%s', $this->formatter->format('--'.$option->getName(), 'INFO'), $option->getShortcut() ? sprintf('(-%s) ', $option->getShortcut()) : '', $option->getHelp(), $default, $multiple) ."\n";89 $messages[] = sprintf(' %-'.$max.'s %s%s%s%s', $this->formatter->format('--'.$option->getName(), 'INFO'), $option->getShortcut() ? sprintf('(-%s) ', $option->getShortcut()) : '', $option->getHelp(), $default, $multiple); 90 90 } 91 91 92 $messages[] = "\n";92 $messages[] = ''; 93 93 } 94 94 95 95 if ($detailedDescription = $task->getDetailedDescription()) 96 96 { 97 $messages[] = $this->formatter->format( "Description:\n", 'COMMENT');97 $messages[] = $this->formatter->format('Description:', 'COMMENT'); 98 98 99 99 $messages[] = ' '.implode("\n ", explode("\n", $detailedDescription))."\n"; trunk/lib/task/help/sfListTask.class.php
r5232 r5250 78 78 if ($arguments['namespace']) 79 79 { 80 $messages[] = $this->formatter->format(sprintf("Available tasks for the \"%s\" namespace: \n", $arguments['namespace']), 'COMMENT');80 $messages[] = $this->formatter->format(sprintf("Available tasks for the \"%s\" namespace:", $arguments['namespace']), 'COMMENT'); 81 81 } 82 82 else 83 83 { 84 $messages[] = $this->formatter->format( "Available tasks:\n", 'COMMENT');84 $messages[] = $this->formatter->format('Available tasks:', 'COMMENT'); 85 85 } 86 86 … … 93 93 { 94 94 $currentNamespace = $task->getNamespace(); 95 $messages[] = sprintf("%s\n", $this->formatter->format($task->getNamespace(), 'COMMENT'));95 $messages[] = $this->formatter->format($task->getNamespace(), 'COMMENT'); 96 96 } 97 97 98 98 $aliases = $task->getAliases() ? $this->formatter->format(' ('.implode(', ', $task->getAliases()).')', 'COMMENT') : ''; 99 99 100 $messages[] = sprintf(" %-${width}s %s%s \n", $this->formatter->format(':'.$task->getName(), 'INFO'), $task->getBriefDescription(), $aliases);100 $messages[] = sprintf(" %-${width}s %s%s", $this->formatter->format(':'.$task->getName(), 'INFO'), $task->getBriefDescription(), $aliases); 101 101 } 102 102 trunk/lib/task/plugin/sfPluginBaseTask.class.php
r5232 r5250 8 8 * file that was distributed with this source code. 9 9 */ 10 11 // Remove E_STRICT from error_reporting12 error_reporting(error_reporting() ^ E_STRICT);13 date_default_timezone_set('UTC');14 15 require_once 'PEAR.php';16 require_once 'PEAR/Frontend.php';17 require_once 'PEAR/Config.php';18 require_once 'PEAR/Registry.php';19 require_once 'PEAR/Command.php';20 require_once 'PEAR/Remote.php';21 require_once 'PEAR/Downloader.php';22 require_once 'PEAR/Frontend/CLI.php';23 require_once 'PEAR/PackageFile/v2/rw.php';24 10 25 11 /** … … 33 19 abstract class sfPluginBaseTask extends sfBaseTask 34 20 { 35 protected 36 $config = null, 37 $registry = null, 38 $frontend = null; 21 private 22 $pluginManager = null; 39 23 40 /** 41 * @see sfTask 42 */ 43 protected function doRun(sfCommandManager $commandManager, $options) 24 public function getPluginManager() 44 25 { 45 // initialize some PEAR objects 46 $this->initConfig(); 47 $this->initRegistry(); 48 $this->initFrontend(); 26 if (is_null($this->pluginManager)) 27 { 28 $environment = new sfPearEnvironment($this->dispatcher, array( 29 'plugin_dir' => sfConfig::get('sf_plugins_dir'), 30 'cache_dir' => sfConfig::get('sf_root_cache_dir').'/.pear', 31 'web_dir' => sfConfig::get('sf_web_dir'), 32 )); 49 33 50 // register channels 51 $this->registerChannel('pear.symfony-project.com'); 52 $this->config->set('default_channel', 'symfony'); 53 54 // register symfony for dependencies 55 $this->registerSymfonyPackage(); 56 57 return parent::doRun($commandManager, $options); 58 } 59 60 protected function pearRunCommand($command, $opts, $params) 61 { 62 $cmd = PEAR_Command::factory($command, $this->config); 63 if (PEAR::isError($cmd)) 64 { 65 throw new sfException('PEAR Error: '.$cmd->getMessage()); 34 $this->pluginManager = new sfSymfonyPluginManager($this->dispatcher, $environment); 66 35 } 67 36 68 $ok = $cmd->run($command, $opts, $params); 69 if (PEAR::isError($ok)) 70 { 71 throw new sfException('PEAR Error: '.$ok->getMessage()); 72 } 73 } 74 75 protected function registerChannel($channel) 76 { 77 $this->config->set('auto_discover', true); 78 79 if (!$this->registry->channelExists($channel, true)) 80 { 81 $downloader = new PEAR_Downloader($this->frontend, array(), $this->config); 82 if (!$downloader->discover($channel)) 83 { 84 throw new sfException(sprintf('Unable to register channel "%s"', $channel)); 85 } 86 } 87 } 88 89 protected function initFrontend() 90 { 91 $this->frontend = PEAR_Frontend::singleton('PEAR_Frontend_symfony'); 92 if (PEAR::isError($this->frontend)) 93 { 94 throw new sfException('PEAR Error: '.$this->frontend->getMessage()); 95 } 96 97 $this->frontend->setEventDispatcher($this->dispatcher); 98 $this->frontend->setFormatter($this->formatter); 99 } 100 101 protected function initRegistry() 102 { 103 $this->registry = $this->config->getRegistry(); 104 if (PEAR::isError($this->registry)) 105 { 106 throw new sfException(sprintf('PEAR Error: Unable to initialize PEAR registry "%s"', $this->registry->getMessage())); 107 } 108 } 109 110 protected function registerSymfonyPackage() 111 { 112 $symfony = new PEAR_PackageFile_v2_rw(); 113 $symfony->setPackage('symfony'); 114 $symfony->setChannel('pear.symfony-project.com'); 115 $symfony->setConfig($this->config); 116 $symfony->setPackageType('php'); 117 $symfony->setAPIVersion('1.1.0'); 118 $symfony->setAPIStability('stable'); 119 $symfony->setReleaseVersion(preg_replace('/\-\w+$/', '', sfCore::VERSION)); 120 $symfony->setReleaseStability('stable'); 121 $symfony->setDate(date('Y-m-d')); 122 $symfony->setDescription('symfony'); 123 $symfony->setSummary('symfony'); 124 $symfony->setLicense('MIT License'); 125 $symfony->clearContents(); 126 $symfony->resetFilelist(); 127 $symfony->addMaintainer('lead', 'fabpot', 'Fabien Potencier', 'fabien.potencier@symfony-project.com'); 128 $symfony->setNotes('-'); 129 $symfony->setPearinstallerDep('1.4.3'); 130 $symfony->setPhpDep('5.1.0'); 131 132 $this->registry->deletePackage('symfony', 'pear.symfony-project.com'); 133 $this->registry->addPackage2($symfony); 134 } 135 136 protected function initConfig() 137 { 138 $this->config = PEAR_Config::singleton(); 139 140 // change the configuration for symfony use 141 $this->config->set('php_dir', sfConfig::get('sf_plugins_dir')); 142 $this->config->set('data_dir', sfConfig::get('sf_plugins_dir')); 143 $this->config->set('test_dir', sfConfig::get('sf_plugins_dir')); 144 $this->config->set('doc_dir', sfConfig::get('sf_plugins_dir')); 145 $this->config->set('bin_dir', sfConfig::get('sf_plugins_dir')); 146 147 // change the PEAR temp dir 148 $cacheDir = sfConfig::get('sf_root_cache_dir').'/.pear'; 149 $this->filesystem->mkdirs($cacheDir, 0777); 150 $this->config->set('cache_dir', $cacheDir); 151 $this->config->set('download_dir', $cacheDir); 152 $this->config->set('tmp_dir', $cacheDir); 153 154 $this->config->set('verbose', 1); 155 } 156 157 protected function getPluginName($package) 158 { 159 $pluginName = (false !== $pos = strrpos($package, '/')) ? substr($package, $pos + 1) : $package; 160 $pluginName = (false !== $pos = strrpos($pluginName, '-')) ? substr($pluginName, 0, $pos) : $pluginName; 161 162 return $pluginName; 163 } 164 165 protected function installWebContent($package) 166 { 167 $pluginName = $this->getPluginName($package); 168 169 $webDir = sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.$pluginName.DIRECTORY_SEPARATOR.'web'; 170 if (is_dir($webDir)) 171 { 172 $this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->formatSection('plugin', 'installing web data for plugin')))); 173 174 $this->filesystem->symlink($webDir, sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$pluginName, true); 175 } 176 } 177 178 protected function uninstallWebContent($package) 179 { 180 $pluginName = $this->getPluginName($package); 181 182 $targetDir = sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$pluginName; 183 if (is_dir($targetDir)) 184 { 185 $this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->formatSection('plugin', 'uninstalling web data for plugin')))); 186 if (is_link($targetDir)) 187 { 188 $this->filesystem->remove($targetDir); 189 } 190 else 191 { 192 $this->filesystem->remove(sfFinder::type('any')->in($targetDir)); 193 $this->filesystem->remove($targetDir); 194 } 195 } 37 return $this->pluginManager; 196 38 } 197 39 } 198 199 class PEAR_Frontend_symfony extends PEAR_Frontend_CLI200 {201 protected202 $dispatcher = null,203 $formatter = null;204 205 public function setEventDispatcher(sfEventDispatcher $dispatcher)206 {207 $this->dispatcher = $dispatcher;208 }209 210 public function setFormatter(sfFormatter $formatter)211 {212 $this->formatter = $formatter;213 }214 215 public function _displayLine($text)216 {217 $this->_display($text);218 }219 220 public function _display($text)221 {222 $this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->splitLongLine($text))));223 }224 225 protected function splitLongLine($text)226 {227 $t = '';228 foreach (explode("\n", $text) as $longline)229 {230 foreach (explode("\n", wordwrap($longline, 62)) as $line)231 {232 if ($line = trim($line))233 {234 $t .= $this->formatter->formatSection('pear', $line);235 }236 }237 }238 239 return $t;240 }241 }trunk/lib/task/plugin/sfPluginInstallTask.class.php
r5232 r5250 28 28 )); 29 29 30 $this->addOptions(array( 31 new sfCommandOption('stability', 's', sfCommandOption::PARAMETER_REQUIRED, 'The preferred stability (stable, beta, alpha)', null), 32 new sfCommandOption('release', 'r', sfCommandOption::PARAMETER_REQUIRED, 'The preferred version', null), 33 new sfCommandOption('channel', 'c', sfCommandOption::PARAMETER_REQUIRED, 'The PEAR channel name', null), 34 new sfCommandOption('install_deps', 'd', sfCommandOption::PARAMETER_NONE, 'Whether to force installation of required dependencies', null), 35 )); 36 30 37 $this->aliases = array('plugin-install'); 31 38 $this->namespace = 'plugin'; … … 37 44 The [plugin:install|INFO] task installs a plugin: 38 45 39 [./symfony plugin:install http://plugins.symfony-project.com/sfGuargPlugin|INFO]46 [./symfony plugin:install sfGuargPlugin|INFO] 40 47 41 You can also install a local plugin archive by giving the path instead of 42 an URL: 48 By default, it installs the latest [stable|COMMENT] release. 43 49 44 [./symfony plugin:install /Users/fabien/plugins/sfGuargPlugin-1.0.0.tgz|INFO] 50 If you want to install a plugin that is not stable yet, 51 use the [stability|COMMENT] option: 52 53 [./symfony plugin:install --stability=beta sfGuargPlugin|INFO] 54 [./symfony plugin:install -s beta sfGuargPlugin|INFO] 55 56 You can also force the installation of a specific version: 57 58 [./symfony plugin:install --release=1.0.0 sfGuargPlugin|INFO] 59 [./symfony plugin:install -r 1.0.0 sfGuargPlugin|INFO] 60 61 To force installation of all required dependencies, use the [install_deps|INFO] flag: 62 63 [./symfony plugin:install --install-deps sfGuargPlugin|INFO] 64 [./symfony plugin:install -d sfGuargPlugin|INFO] 65 66 By default, the PEAR channel used is [symfony-plugins|INFO] 67 (plugins.symfony-project.org). 68 69 You can specify another channel with the [channel|COMMENT] option: 70 71 [./symfony plugin:install --channel=mypearchannel sfGuargPlugin|INFO] 72 [./symfony plugin:install -c mypearchannel sfGuargPlugin|INFO] 73 74 You can also install PEAR packages hosted on a website: 75 76 [./symfony plugin:install http://somewhere.example.com/sfGuargPlugin-1.0.0.tgz|INFO] 77 78 Or local PEAR packages: 79 80 [./symfony plugin:install /home/fabien/plugins/sfGuargPlugin-1.0.0.tgz|INFO] 45 81 46 82 If the plugin contains some web content (images, stylesheets or javascripts), … … 55 91 protected function execute($arguments = array(), $options = array()) 56 92 { 57 $packages = array($arguments['name']);58 93 $this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->formatSection('plugin', sprintf('installing plugin "%s"', $arguments['name']))))); 59 list($ret, $error) = $this->pearRunCommand('install', array(), $packages);60 94 61 if ($error) 62 { 63 throw new sfCommandException($error); 64 } 65 66 $this->installWebContent($arguments['name']); 95 $this->getPuginManager()->installPlugin($arguments['name'], $options); 67 96 } 68 97 } trunk/lib/task/plugin/sfPluginListTask.class.php
r5232 r5250 44 44 protected function execute($arguments = array(), $options = array()) 45 45 { 46 $this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->format( "Installed plugins:\n", 'COMMENT'))));46 $this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->format('Installed plugins:', 'COMMENT')))); 47 47 48 $installed = $this->registry->packageInfo(null, null, null); 49 foreach ($installed as $channel => $packages) 48 foreach ($this->getPuginManager()->getInstalledPlugins() as $package) 50 49 { 51 foreach ($packages as $package) 52 { 53 $pobj = $this->registry->getPackage(isset($package['package']) ? $package['package'] : $package['name'], $channel); 54 $this->dispatcher->notify(new sfEvent($this, 'command.log', array(sprintf(" %-40s %10s-%-6s %s\n", $this->formatter->format($pobj->getPackage(), 'INFO'), $pobj->getVersion(), $pobj->getState() ? $pobj->getState() : null, $this->formatter->format(sprintf('# %s (%s)', $channel, $this->registry->getChannel($channel)->getAlias()), 'COMMENT'))))); 55 } 50 $alias = $this->getPuginManager()->getRegistry()->getChannel($package->getChannel())->getAlias(); 51 $this->dispatcher->notify(new sfEvent($this, 'command.log', array(sprintf(' %-40s %10s-%-6s %s', $this->formatter->format($package->getPackage(), 'INFO'), $package->getVersion(), $package->getState() ? $package->getState() : null, $this->formatter->format(sprintf('# %s (%s)', $package->getChannel(), $alias), 'COMMENT'))))); 56 52 } 57 53 } trunk/lib/task/plugin/sfPluginUninstallTask.class.php
r5232 r5250 28 28 )); 29 29 30 $this->addOptions(array( 31 new sfCommandOption('channel', 'c', sfCommandOption::PARAMETER_REQUIRED, 'The PEAR channel name', null), 32 new sfCommandOption('install_deps', 'd', sfCommandOption::PARAMETER_NONE, 'Whether to force installation of dependencies', null), 33 )); 34 30 35 $this->aliases = array('plugin-uninstall'); 31 36 $this->namespace = 'plugin'; … … 37 42 The [plugin:uninstall|INFO] task uninstalls a plugin: 38 43 39 [./symfony plugin:uninstall symfony/sfGuargPlugin|INFO] 44 [./symfony plugin:uninstall sfGuargPlugin|INFO] 45 46 The default channel is [symfony|INFO]. 47 48 You can also uninstall a plugin which has a different channel: 49 50 [./symfony plugin:uninstall --channel=mypearchannel sfGuargPlugin|INFO] 51 52 [./symfony plugin:uninstall -c mypearchannel sfGuargPlugin|INFO] 53 54 You can get the PEAR channel name of a plugin by launching the 55 [plugin:list] task. 40 56 41 57 If the plugin contains some web content (images, stylesheets or javascripts), … … 50 66 protected function execute($arguments = array(), $options = array()) 51 67 { 52 $this-> uninstallWebContent($arguments['name']);68 $this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->formatSection('plugin', sprintf('uninstalling plugin "%s"', $arguments['name']))))); 53 69 54 $packages = array($arguments['name']); 55 $this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->formatSection('plugin', sprintf('uninstalling plugin "%s"', $arguments['name']))))); 56 list($ret, $error) = $this->pearRunCommand('uninstall', array(), $packages); 57 58 if ($error) 59 { 60 throw new sfCommandException($error); 61 } 70 $this->getPuginManager()->uninstallPlugin($arguments['name'], $options); 62 71 } 63 72 } trunk/lib/task/plugin/sfPluginUpgradeTask.class.php
r5232 r5250 28 28 )); 29 29 30 $this->addOptions(array( 31 new sfCommandOption('stability', 's', sfCommandOption::PARAMETER_REQUIRED, 'The preferred stability (stable, beta, alpha)', null), 32 new sfCommandOption('release', 'r', sfCommandOption::PARAMETER_REQUIRED, 'The preferred version', null), 33 new sfCommandOption('channel', 'c', sfCommandOption::PARAMETER_REQUIRED, 'The PEAR channel name', null), 34 )); 35 30 36 $this->aliases = array('plugin-upgrade'); 31 37 $this->namespace = 'plugin'; … … 37 43 The [plugin:upgrade|INFO] task tries to upgrade a plugin: 38 44 39 [./symfony plugin:upgrade symfony/sfGuargPlugin|INFO] 45 [./symfony plugin:upgrade sfGuargPlugin|INFO] 46 47 The default channel is [symfony|INFO]. 40 48 41 49 If the plugin contains some web content (images, stylesheets or javascripts), 42 50 the task also updates the [web/%name%|COMMENT] directory content on Windows. 51 52 See [plugin:install|INFO] for more information about the format of the plugin name and options. 43 53 EOF; 44 54 } … … 49 59 protected function execute($arguments = array(), $options = array()) 50 60 { 51 $packages = array($arguments['name']);52 61 $this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->formatSection('plugin', sprintf('upgrading plugin "%s"', $arguments['name']))))); 53 list($ret, $error) = $this->pearRunCommand('upgrade', array('loose' => true, 'nodeps' => true), $packages);54 62 55 if ($error) 56 { 57 throw new sfCommandException($error); 58 } 59 60 $this->uninstallWebContent($arguments['name']); 61 $this->installWebContent($arguments['name']); 63 $this->getPuginManager()->installPlugin($arguments['name'], $options); 62 64 } 63 65 } trunk/lib/task/sfFilesystem.class.php
r5232 r5250 324 324 $message = $this->formatter ? $this->formatter->formatSection($section, $text, $size) : $section.' '.$text."\n"; 325 325 326 $this->dispatcher->notify(new sfEvent($this, ' application.log', array($message)));326 $this->dispatcher->notify(new sfEvent($this, 'command.log', array($message))); 327 327 } 328 328 }

