Development

Changeset 5250

You must first sign up to be able to contribute.

Changeset 5250

Show
Ignore:
Timestamp:
09/24/07 10:11:50 (2 years ago)
Author:
fabien
Message:

new plugin system

  • the plugin system can be used by itself (no symfony dependency)
  • new plugin/ directory with all plugin related classes
    • those classes can be used by themselves in your code (see unit tests for some examples)
  • leveraged PEAR channels:
    • use of the full PEAR REST API
    • it's now possible to install plugins hosted on any PEAR channel
    • dependencies are now checked
    • last version guess now takes into account stability and symfony version
  • added more options to the CLI tasks:
    • --install_deps: to automatically install required dependencies
    • --release: to install a specific plugin release
    • --stability: to change the preferred stability (stable by default)
    • --channel: to install plugins from other PEAR channels
  • added some events:
    • plugin.pre_install
    • plugin.post_install
    • plugin.pre_uninstall
    • plugin.post_uninstall
  • added the possibility to mock all HTTP related layers of PEAR (PEAR_REST, PEAR_Downloader)
  • added full unit tests for all the features

The symfony plugin repository is comptatible with symfony 1.0 and 1.1.

The new repository will be at plugins.symfony-project.org (.org and not .com).
It will be up this week. In the meantime, it's not possible to install plugins
via the plugin:* tasks. The new backend won't accept plugins with "non-compliant"
licenses.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/data/bin/symfony.php

    r5232 r5250  
    3030  $logger = new sfCommandLogger($dispatcher); 
    3131 
    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); 
    3338  $application->run(); 
    3439} 
    3540catch (Exception $e) 
    3641{ 
     42  if (!isset($application)) 
     43  { 
     44    throw $e; 
     45  } 
     46 
    3747  $application->renderException($e); 
     48 
    3849  exit(1); 
    3950} 
  • trunk/lib/command/sfAnsiColorFormatter.class.php

    r5232 r5250  
    9696    $width = 9 + strlen($this->format('', 'INFO')); 
    9797 
    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)); 
    9999  } 
    100100 
  • trunk/lib/command/sfCommandLogger.class.php

    r5232 r5250  
    4040  { 
    4141    $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 
    4252    foreach ($event->getParameterHolder()->getAll() as $message) 
    4353    { 
    44       $this->log(sprintf('%s', $message), $priority); 
     54      $this->log(sprintf('%s%s', $prefix, $message), $priority); 
    4555    } 
    4656  } 
  • trunk/lib/command/sfFormatter.class.php

    r5232 r5250  
    5050  public function formatSection($section, $text, $size = null) 
    5151  { 
    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)); 
    5553  } 
    5654 
  • trunk/lib/task/help/sfHelpTask.class.php

    r5232 r5250  
    4747    $messages = array(); 
    4848 
    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"; 
    5151 
    5252    // find the largest option or argument name 
     
    6464    if ($task->getAliases()) 
    6565    { 
    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"; 
    6767    } 
    6868 
    6969    if ($task->getArguments()) 
    7070    { 
    71       $messages[] = $this->formatter->format("Arguments:\n", 'COMMENT'); 
     71      $messages[] = $this->formatter->format('Arguments:', 'COMMENT'); 
    7272      foreach ($task->getArguments() as $argument) 
    7373      { 
    7474        $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); 
    7676      } 
    7777 
    78       $messages[] = "\n"
     78      $messages[] = ''
    7979    } 
    8080 
    8181    if ($task->getOptions()) 
    8282    { 
    83       $messages[] = $this->formatter->format("Options:\n", 'COMMENT'); 
     83      $messages[] = $this->formatter->format('Options:', 'COMMENT'); 
    8484 
    8585      foreach ($task->getOptions() as $option) 
     
    8787        $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') : ''; 
    8888        $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)
    9090      } 
    9191 
    92       $messages[] = "\n"
     92      $messages[] = ''
    9393    } 
    9494 
    9595    if ($detailedDescription = $task->getDetailedDescription()) 
    9696    { 
    97       $messages[] = $this->formatter->format("Description:\n", 'COMMENT'); 
     97      $messages[] = $this->formatter->format('Description:', 'COMMENT'); 
    9898 
    9999      $messages[] = ' '.implode("\n ", explode("\n", $detailedDescription))."\n"; 
  • trunk/lib/task/help/sfListTask.class.php

    r5232 r5250  
    7878    if ($arguments['namespace']) 
    7979    { 
    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'); 
    8181    } 
    8282    else 
    8383    { 
    84       $messages[] = $this->formatter->format("Available tasks:\n", 'COMMENT'); 
     84      $messages[] = $this->formatter->format('Available tasks:', 'COMMENT'); 
    8585    } 
    8686 
     
    9393      { 
    9494        $currentNamespace = $task->getNamespace(); 
    95         $messages[] = sprintf("%s\n", $this->formatter->format($task->getNamespace(), 'COMMENT')); 
     95        $messages[] = $this->formatter->format($task->getNamespace(), 'COMMENT'); 
    9696      } 
    9797 
    9898      $aliases = $task->getAliases() ? $this->formatter->format(' ('.implode(', ', $task->getAliases()).')', 'COMMENT') : ''; 
    9999 
    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); 
    101101    } 
    102102 
  • trunk/lib/task/plugin/sfPluginBaseTask.class.php

    r5232 r5250  
    88 * file that was distributed with this source code. 
    99 */ 
    10  
    11 // Remove E_STRICT from error_reporting 
    12 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'; 
    2410 
    2511/** 
     
    3319abstract class sfPluginBaseTask extends sfBaseTask 
    3420{ 
    35   protected 
    36    $config   = null, 
    37    $registry = null, 
    38    $frontend = null; 
     21  private 
     22   $pluginManager = null; 
    3923 
    40   /** 
    41    * @see sfTask 
    42    */ 
    43   protected function doRun(sfCommandManager $commandManager, $options) 
     24  public function getPluginManager() 
    4425  { 
    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      )); 
    4933 
    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); 
    6635    } 
    6736 
    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; 
    19638  } 
    19739} 
    198  
    199 class PEAR_Frontend_symfony extends PEAR_Frontend_CLI 
    200 { 
    201   protected 
    202     $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  
    2828    )); 
    2929 
     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 
    3037    $this->aliases = array('plugin-install'); 
    3138    $this->namespace = 'plugin'; 
     
    3744The [plugin:install|INFO] task installs a plugin: 
    3845 
    39   [./symfony plugin:install http://plugins.symfony-project.com/sfGuargPlugin|INFO] 
     46  [./symfony plugin:install sfGuargPlugin|INFO] 
    4047 
    41 You can also install a local plugin archive by giving the path instead of 
    42 an URL: 
     48By default, it installs the latest [stable|COMMENT] release. 
    4349 
    44   [./symfony plugin:install /Users/fabien/plugins/sfGuargPlugin-1.0.0.tgz|INFO] 
     50If you want to install a plugin that is not stable yet, 
     51use the [stability|COMMENT] option: 
     52 
     53  [./symfony plugin:install --stability=beta sfGuargPlugin|INFO] 
     54  [./symfony plugin:install -s beta sfGuargPlugin|INFO] 
     55 
     56You 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 
     61To 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 
     66By default, the PEAR channel used is [symfony-plugins|INFO] 
     67(plugins.symfony-project.org). 
     68 
     69You 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 
     74You 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 
     78Or local PEAR packages: 
     79 
     80  [./symfony plugin:install /home/fabien/plugins/sfGuargPlugin-1.0.0.tgz|INFO] 
    4581 
    4682If the plugin contains some web content (images, stylesheets or javascripts), 
     
    5591  protected function execute($arguments = array(), $options = array()) 
    5692  { 
    57     $packages = array($arguments['name']); 
    5893    $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); 
    6094 
    61     if ($error) 
    62     { 
    63       throw new sfCommandException($error); 
    64     } 
    65  
    66     $this->installWebContent($arguments['name']); 
     95    $this->getPuginManager()->installPlugin($arguments['name'], $options); 
    6796  } 
    6897} 
  • trunk/lib/task/plugin/sfPluginListTask.class.php

    r5232 r5250  
    4444  protected function execute($arguments = array(), $options = array()) 
    4545  { 
    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')))); 
    4747 
    48     $installed = $this->registry->packageInfo(null, null, null); 
    49     foreach ($installed as $channel => $packages) 
     48    foreach ($this->getPuginManager()->getInstalledPlugins() as $package) 
    5049    { 
    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'))))); 
    5652    } 
    5753  } 
  • trunk/lib/task/plugin/sfPluginUninstallTask.class.php

    r5232 r5250  
    2828    )); 
    2929 
     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 
    3035    $this->aliases = array('plugin-uninstall'); 
    3136    $this->namespace = 'plugin'; 
     
    3742The [plugin:uninstall|INFO] task uninstalls a plugin: 
    3843 
    39   [./symfony plugin:uninstall symfony/sfGuargPlugin|INFO] 
     44  [./symfony plugin:uninstall sfGuargPlugin|INFO] 
     45 
     46The default channel is [symfony|INFO]. 
     47 
     48You 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 
     54You can get the PEAR channel name of a plugin by launching the 
     55[plugin:list] task. 
    4056 
    4157If the plugin contains some web content (images, stylesheets or javascripts), 
     
    5066  protected function execute($arguments = array(), $options = array()) 
    5167  { 
    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']))))); 
    5369 
    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); 
    6271  } 
    6372} 
  • trunk/lib/task/plugin/sfPluginUpgradeTask.class.php

    r5232 r5250  
    2828    )); 
    2929 
     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 
    3036    $this->aliases = array('plugin-upgrade'); 
    3137    $this->namespace = 'plugin'; 
     
    3743The [plugin:upgrade|INFO] task tries to upgrade a plugin: 
    3844 
    39   [./symfony plugin:upgrade symfony/sfGuargPlugin|INFO] 
     45  [./symfony plugin:upgrade sfGuargPlugin|INFO] 
     46 
     47The default channel is [symfony|INFO]. 
    4048 
    4149If the plugin contains some web content (images, stylesheets or javascripts), 
    4250the task also updates the [web/%name%|COMMENT] directory content on Windows. 
     51 
     52See [plugin:install|INFO] for more information about the format of the plugin name and options. 
    4353EOF; 
    4454  } 
     
    4959  protected function execute($arguments = array(), $options = array()) 
    5060  { 
    51     $packages = array($arguments['name']); 
    5261    $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); 
    5462 
    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); 
    6264  } 
    6365} 
  • trunk/lib/task/sfFilesystem.class.php

    r5232 r5250  
    324324    $message = $this->formatter ? $this->formatter->formatSection($section, $text, $size) : $section.' '.$text."\n"; 
    325325 
    326     $this->dispatcher->notify(new sfEvent($this, 'application.log', array($message))); 
     326    $this->dispatcher->notify(new sfEvent($this, 'command.log', array($message))); 
    327327  } 
    328328} 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.