Development

/branches/1.2/lib/task/plugin/sfPluginPublishAssetsTask.class.php

You must first sign up to be able to contribute.

root/branches/1.2/lib/task/plugin/sfPluginPublishAssetsTask.class.php

Revision 13929, 2.4 kB (checked in by FabianLange, 5 years ago)

[1.2] publish-assets now works correctly for all active plugins, even when they set the plugin path to a different directory. fixes #5163. refs #4926

  • Property svn:mergeinfo set to
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) 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  * Publishes Web Assets for Core and third party plugins
15  *
16  * @package    symfony
17  * @subpackage task
18  * @author     Fabian Lange <fabian.lange@symfony-project.com>
19  * @version    SVN: $Id: sfPluginPublishAssetsTask.class.php 7655 2008-02-28 09:52:40Z fabien $
20  */
21 class sfPluginPublishAssetsTask extends sfPluginBaseTask
22 {
23   /**
24    * @see sfTask
25    */
26   protected function configure()
27   {
28     $this->addOptions(array(
29       new sfCommandOption('core-only', '', sfCommandOption::PARAMETER_NONE, 'If set only core plugins will publish their assets'),
30       new sfCommandOption('symfony-lib-dir', '', sfCommandOption::PARAMETER_REQUIRED, 'The symfony lib dir'),
31     ));
32
33     $this->aliases = array();
34     $this->namespace = 'plugin';
35     $this->name = 'publish-assets';
36
37     $this->briefDescription = 'Publishes web assets for all plugins';
38
39     $this->detailedDescription = <<<EOF
40 The [plugin:publish-assets|INFO] task will publish web assets from all plugins.
41
42   [./symfony plugin:publish-assets|INFO]
43
44 In fact this will send the [plugin.post_install|INFO] event to each plugin.
45
46 EOF;
47   }
48
49   /**
50    * @see sfTask
51    */
52   protected function execute($arguments = array(), $options = array())
53   {
54     $plugins = $this->configuration->getPlugins();
55
56     foreach ($this->configuration->getAllPluginPaths() as $pluginName => $pluginPath)
57     {
58       if (!in_array($pluginName, $plugins) || ($options['core-only'] && dirname($pluginPath) != $this->configuration->getSymfonyLibDir().'/plugins'))
59       {
60         continue;
61       }
62
63       $this->logSection('plugin', 'Configuring plugin - '.$pluginName);
64       $this->installPluginAssets($pluginName, $pluginPath);
65     }
66   }
67
68   /**
69    * Installs web content for a plugin.
70    *
71    * @param string $plugin The plugin name
72    * @param string $dir    The plugin directory
73    */
74   protected function installPluginAssets($plugin, $dir)
75   {
76     $webDir = $dir.DIRECTORY_SEPARATOR.'web';
77
78     if (is_dir($webDir))
79     {
80       $filesystem = new sfFilesystem();
81       $filesystem->relativeSymlink($webDir, sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$plugin, true);
82     }
83   }
84 }
85
Note: See TracBrowser for help on using the browser.