| 1 |
lars |
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 |
require_once(dirname(__FILE__).'/sfPluginBaseTask.class.php');
|
|
|
12 |
|
|
|
13 |
/**
|
|
|
14 |
* Installs a plugin.
|
|
|
15 |
*
|
|
|
16 |
* @package symfony
|
|
|
17 |
* @subpackage task
|
|
|
18 |
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
19 |
* @version SVN: $Id: sfPluginInstallTask.class.php 23922 2009-11-14 14:58:38Z fabien $
|
|
|
20 |
*/
|
|
|
21 |
class sfPluginInstallTask extends sfPluginBaseTask
|
|
|
22 |
{
|
|
|
23 |
/**
|
|
|
24 |
* @see sfTask
|
|
|
25 |
*/
|
|
|
26 |
protected function configure()
|
|
|
27 |
{
|
|
|
28 |
$this->addArguments(array(
|
|
|
29 |
new sfCommandArgument('name', sfCommandArgument::REQUIRED, 'The plugin name'),
|
|
|
30 |
));
|
|
|
31 |
|
|
|
32 |
$this->addOptions(array(
|
|
|
33 |
new sfCommandOption('stability', 's', sfCommandOption::PARAMETER_REQUIRED, 'The preferred stability (stable, beta, alpha)', null),
|
|
|
34 |
new sfCommandOption('release', 'r', sfCommandOption::PARAMETER_REQUIRED, 'The preferred version', null),
|
|
|
35 |
new sfCommandOption('channel', 'c', sfCommandOption::PARAMETER_REQUIRED, 'The PEAR channel name', null),
|
|
|
36 |
new sfCommandOption('install_deps', 'd', sfCommandOption::PARAMETER_NONE, 'Whether to force installation of required dependencies', null),
|
|
|
37 |
new sfCommandOption('force-license', null, sfCommandOption::PARAMETER_NONE, 'Whether to force installation even if the license is not MIT like'),
|
|
|
38 |
));
|
|
|
39 |
|
|
|
40 |
$this->namespace = 'plugin';
|
|
|
41 |
$this->name = 'install';
|
|
|
42 |
|
|
|
43 |
$this->briefDescription = 'Installs a plugin';
|
|
|
44 |
|
|
|
45 |
$this->detailedDescription = <<<EOF
|
|
|
46 |
The [plugin:install|INFO] task installs a plugin:
|
|
|
47 |
|
|
|
48 |
[./symfony plugin:install sfGuardPlugin|INFO]
|
|
|
49 |
|
|
|
50 |
By default, it installs the latest [stable|COMMENT] release.
|
|
|
51 |
|
|
|
52 |
If you want to install a plugin that is not stable yet,
|
|
|
53 |
use the [stability|COMMENT] option:
|
|
|
54 |
|
|
|
55 |
[./symfony plugin:install --stability=beta sfGuardPlugin|INFO]
|
|
|
56 |
[./symfony plugin:install -s beta sfGuardPlugin|INFO]
|
|
|
57 |
|
|
|
58 |
You can also force the installation of a specific version:
|
|
|
59 |
|
|
|
60 |
[./symfony plugin:install --release=1.0.0 sfGuardPlugin|INFO]
|
|
|
61 |
[./symfony plugin:install -r 1.0.0 sfGuardPlugin|INFO]
|
|
|
62 |
|
|
|
63 |
To force installation of all required dependencies, use the [install_deps|INFO] flag:
|
|
|
64 |
|
|
|
65 |
[./symfony plugin:install --install-deps sfGuardPlugin|INFO]
|
|
|
66 |
[./symfony plugin:install -d sfGuardPlugin|INFO]
|
|
|
67 |
|
|
|
68 |
By default, the PEAR channel used is [symfony-plugins|INFO]
|
|
|
69 |
(plugins.symfony-project.org).
|
|
|
70 |
|
|
|
71 |
You can specify another channel with the [channel|COMMENT] option:
|
|
|
72 |
|
|
|
73 |
[./symfony plugin:install --channel=mypearchannel sfGuardPlugin|INFO]
|
|
|
74 |
[./symfony plugin:install -c mypearchannel sfGuardPlugin|INFO]
|
|
|
75 |
|
|
|
76 |
You can also install PEAR packages hosted on a website:
|
|
|
77 |
|
|
|
78 |
[./symfony plugin:install http://somewhere.example.com/sfGuardPlugin-1.0.0.tgz|INFO]
|
|
|
79 |
|
|
|
80 |
Or local PEAR packages:
|
|
|
81 |
|
|
|
82 |
[./symfony plugin:install /home/fabien/plugins/sfGuardPlugin-1.0.0.tgz|INFO]
|
|
|
83 |
|
|
|
84 |
If the plugin contains some web content (images, stylesheets or javascripts),
|
|
|
85 |
the task creates a [%name%|COMMENT] symbolic link for those assets under [web/|COMMENT].
|
|
|
86 |
On Windows, the task copy all the files to the [web/%name%|COMMENT] directory.
|
|
|
87 |
EOF;
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
/**
|
|
|
91 |
* @see sfTask
|
|
|
92 |
*/
|
|
|
93 |
protected function execute($arguments = array(), $options = array())
|
|
|
94 |
{
|
|
|
95 |
$this->logSection('plugin', sprintf('installing plugin "%s"', $arguments['name']));
|
|
|
96 |
|
|
|
97 |
$options['version'] = $options['release'];
|
|
|
98 |
unset($options['release']);
|
|
|
99 |
|
|
|
100 |
// license compatible?
|
|
|
101 |
if (!$options['force-license'])
|
|
|
102 |
{
|
|
|
103 |
try
|
|
|
104 |
{
|
|
|
105 |
$license = $this->getPluginManager()->getPluginLicense($arguments['name'], $options);
|
|
|
106 |
}
|
|
|
107 |
catch (Exception $e)
|
|
|
108 |
{
|
|
|
109 |
throw new sfCommandException(sprintf('%s (use --force-license to force installation)', $e->getMessage()));
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
if (false !== $license)
|
|
|
113 |
{
|
|
|
114 |
$temp = trim(str_replace('license', '', strtolower($license)));
|
|
|
115 |
if (null !== $license && !in_array($temp, array('mit', 'bsd', 'lgpl', 'php', 'apache')))
|
|
|
116 |
{
|
|
|
117 |
throw new sfCommandException(sprintf('The license of this plugin "%s" is not MIT like (use --force-license to force installation).', $license));
|
|
|
118 |
}
|
|
|
119 |
}
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
$this->getPluginManager()->installPlugin($arguments['name'], $options);
|
|
|
123 |
}
|
|
|
124 |
}
|