PageRenderTime 29ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/sbweb/sbweb_logica/lib/symfony/task/plugin/sfPluginInstallTask.class.php

http://opac-sbweb.googlecode.com/
PHP | 129 lines | 77 code | 30 blank | 22 comment | 5 complexity | 159b7f8c94604c8eea5cea0215f70a52 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-3.0
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. require_once(dirname(__FILE__).'/sfPluginBaseTask.class.php');
  10. /**
  11. * Installs a plugin.
  12. *
  13. * @package symfony
  14. * @subpackage task
  15. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  16. * @version SVN: $Id: sfPluginInstallTask.class.php 10198 2008-07-10 11:55:29Z fabien $
  17. */
  18. class sfPluginInstallTask extends sfPluginBaseTask
  19. {
  20. /**
  21. * @see sfTask
  22. */
  23. protected function configure()
  24. {
  25. $this->addArguments(array(
  26. new sfCommandArgument('name', sfCommandArgument::REQUIRED, 'The plugin name'),
  27. ));
  28. $this->addOptions(array(
  29. new sfCommandOption('stability', 's', sfCommandOption::PARAMETER_REQUIRED, 'The preferred stability (stable, beta, alpha)', null),
  30. new sfCommandOption('release', 'r', sfCommandOption::PARAMETER_REQUIRED, 'The preferred version', null),
  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 required dependencies', null),
  33. new sfCommandOption('force-license', null, sfCommandOption::PARAMETER_NONE, 'Whether to force installation even if the license is not MIT like'),
  34. ));
  35. $this->aliases = array('plugin-install');
  36. $this->namespace = 'plugin';
  37. $this->name = 'install';
  38. $this->briefDescription = 'Installs a plugin';
  39. $this->detailedDescription = <<<EOF
  40. The [plugin:install|INFO] task installs a plugin:
  41. [./symfony plugin:install sfGuardPlugin|INFO]
  42. By default, it installs the latest [stable|COMMENT] release.
  43. If you want to install a plugin that is not stable yet,
  44. use the [stability|COMMENT] option:
  45. [./symfony plugin:install --stability=beta sfGuardPlugin|INFO]
  46. [./symfony plugin:install -s beta sfGuardPlugin|INFO]
  47. You can also force the installation of a specific version:
  48. [./symfony plugin:install --release=1.0.0 sfGuardPlugin|INFO]
  49. [./symfony plugin:install -r 1.0.0 sfGuardPlugin|INFO]
  50. To force installation of all required dependencies, use the [install_deps|INFO] flag:
  51. [./symfony plugin:install --install-deps sfGuardPlugin|INFO]
  52. [./symfony plugin:install -d sfGuardPlugin|INFO]
  53. By default, the PEAR channel used is [symfony-plugins|INFO]
  54. (plugins.symfony-project.org).
  55. You can specify another channel with the [channel|COMMENT] option:
  56. [./symfony plugin:install --channel=mypearchannel sfGuardPlugin|INFO]
  57. [./symfony plugin:install -c mypearchannel sfGuardPlugin|INFO]
  58. Or you can use the [channel/package|INFO] notation:
  59. [./symfony plugin:install mypearchannel/sfGuardPlugin|INFO]
  60. You can also install PEAR packages hosted on a website:
  61. [./symfony plugin:install http://somewhere.example.com/sfGuardPlugin-1.0.0.tgz|INFO]
  62. Or local PEAR packages:
  63. [./symfony plugin:install /home/fabien/plugins/sfGuardPlugin-1.0.0.tgz|INFO]
  64. If the plugin contains some web content (images, stylesheets or javascripts),
  65. the task creates a [%name%|COMMENT] symbolic link for those assets under [web/|COMMENT].
  66. On Windows, the task copy all the files to the [web/%name%|COMMENT] directory.
  67. EOF;
  68. }
  69. /**
  70. * @see sfTask
  71. */
  72. protected function execute($arguments = array(), $options = array())
  73. {
  74. $this->logSection('plugin', sprintf('installing plugin "%s"', $arguments['name']));
  75. $options['version'] = $options['release'];
  76. unset($options['release']);
  77. // license compatible?
  78. if (!$options['force-license'])
  79. {
  80. try
  81. {
  82. $license = $this->getPluginManager()->getPluginLicense($arguments['name'], $options);
  83. }
  84. catch (Exception $e)
  85. {
  86. throw new sfCommandException(sprintf('%s (use --force-license to force installation)', $e->getMessage()));
  87. }
  88. if (false !== $license)
  89. {
  90. $temp = trim(str_replace('license', '', strtolower($license)));
  91. if (!is_null($license) && !in_array($temp, array('mit', 'bsd', 'lgpl', 'php', 'apache')))
  92. {
  93. throw new sfCommandException(sprintf('The license of this plugin "%s" is not MIT like (use --force-license to force installation).', $license));
  94. }
  95. }
  96. }
  97. $this->getPluginManager()->installPlugin($arguments['name'], $options);
  98. }
  99. }