123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- <?php
- class sfSymfonyPluginManager extends sfPluginManager
- {
-
- public function initialize(sfEventDispatcher $dispatcher, sfPearEnvironment $environment)
- {
- parent::initialize($dispatcher, $environment);
- if (!$environment->getOption('web_dir'))
- {
- throw new sfPluginException('You must provide a "web_dir" option.');
- }
- }
-
- public function configure()
- {
-
- $this->environment->registerChannel('pear.symfony-project.com', true);
-
- $this->environment->registerChannel('plugins.symfony-project.org', true);
-
- $this->registerSymfonyPackage();
-
- $this->dispatcher->connect('plugin.post_install', array($this, 'ListenToPluginPostInstall'));
- $this->dispatcher->connect('plugin.pre_uninstall', array($this, 'ListenToPluginPostUninstall'));
- }
-
- public function installWebContent($plugin, $sourceDirectory)
- {
- $webDir = $sourceDirectory.DIRECTORY_SEPARATOR.$plugin.DIRECTORY_SEPARATOR.'web';
- if (is_dir($webDir))
- {
- $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Installing web data for plugin')));
- $filesystem = new sfFilesystem();
- $filesystem->relativeSymlink($webDir, $this->environment->getOption('web_dir').DIRECTORY_SEPARATOR.$plugin, true);
- }
- }
-
- public function uninstallWebContent($plugin)
- {
- $targetDir = $this->environment->getOption('web_dir').DIRECTORY_SEPARATOR.$plugin;
- if (is_dir($targetDir))
- {
- $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Uninstalling web data for plugin')));
- $filesystem = new sfFilesystem();
- if (is_link($targetDir))
- {
- $filesystem->remove($targetDir);
- }
- else
- {
- $filesystem->remove(sfFinder::type('any')->in($targetDir));
- $filesystem->remove($targetDir);
- }
- }
- }
-
- public function ListenToPluginPostInstall($event)
- {
- $this->installWebContent($event['plugin'],
- isset($event['plugin_dir']) ? $event['plugin_dir'] : $this->environment->getOption('plugin_dir'));
- }
-
- public function ListenToPluginPostUninstall($event)
- {
- $this->uninstallWebContent($event['plugin']);
- }
-
- protected function registerSymfonyPackage()
- {
- $symfony = new PEAR_PackageFile_v2_rw();
- $symfony->setPackage('symfony');
- $symfony->setChannel('pear.symfony-project.com');
- $symfony->setConfig($this->environment->getConfig());
- $symfony->setPackageType('php');
- $symfony->setAPIVersion('1.1.0');
- $symfony->setAPIStability('stable');
- $symfony->setReleaseVersion(preg_replace('/\-\w+$/', '', SYMFONY_VERSION));
- $symfony->setReleaseStability(false === strpos(SYMFONY_VERSION, 'DEV') ? 'stable' : 'beta');
- $symfony->setDate(date('Y-m-d'));
- $symfony->setDescription('symfony');
- $symfony->setSummary('symfony');
- $symfony->setLicense('MIT License');
- $symfony->clearContents();
- $symfony->resetFilelist();
- $symfony->addMaintainer('lead', 'fabpot', 'Fabien Potencier', 'fabien.potencier@symfony-project.com');
- $symfony->setNotes('-');
- $symfony->setPearinstallerDep('1.4.3');
- $symfony->setPhpDep('5.1.0');
- $this->environment->getRegistry()->deletePackage('symfony', 'pear.symfony-project.com');
- if (!$this->environment->getRegistry()->addPackage2($symfony))
- {
- throw new sfPluginException('Unable to register the symfony package');
- }
- }
-
- protected function isPluginCompatibleWithDependency($dependency)
- {
- if (isset($dependency['channel']) && 'symfony' == $dependency['name'] && 'pear.symfony-project.com' == $dependency['channel'])
- {
- return $this->checkDependency($dependency);
- }
- return true;
- }
- }
|