protected function _initialize() { $cachePath = sfConfig::get('sf_cache_dir') . '/sympal/' . $this->_name . '.cache'; if (!file_exists($cachePath)) { $this->_loadFromSymfonyPlugins(); if ($pluginConfiguration = sfSympalPluginToolkit::isPluginDownloaded($this->_name)) { $downloadPath = sfContext::getInstance()->getConfiguration()->getPluginConfiguration($this->_name)->getRootDir(); } else { $downloadPath = sfSympalPluginToolkit::getPluginDownloadPath($this->_name); } $packageXmlPath = $downloadPath . '/package.xml'; $readmePath = $downloadPath . '/README'; if (sfSympalToolkit::fileGetContents($packageXmlPath)) { $packageXml = simplexml_load_file($packageXmlPath); } else { if (sfSympalToolkit::fileGetContents($packageXmlPath . '.tmpl')) { $packageXml = simplexml_load_file($packageXmlPath . '.tmpl'); } } if (isset($packageXml)) { $package = sfSympalPluginApi::simpleXmlToArray($packageXml); $this->_plugin = array_merge($package, $this->_plugin); } if ($readme = sfSympalToolkit::fileGetContents($readmePath)) { $this->_plugin['readme'] = $readme; } $this->_plugin['name'] = $this->_name; file_put_contents($cachePath, serialize($this->_plugin)); } else { $serialized = file_get_contents($cachePath); $this->_plugin = unserialize($serialized); } }
public function download() { $this->logSection('sympal', sprintf('Downloading Sympal plugin "%s"', $this->_pluginName)); $success = false; try { $this->logSection('sympal', '...trying to download plugin via PEAR'); chdir(sfConfig::get('sf_root_dir')); $pluginInstall = new sfPluginInstallTask($this->_dispatcher, $this->_formatter); $ret = @$pluginInstall->run(array($this->_pluginName), array()); if (!sfSympalPluginToolkit::isPluginInstalled($this->_pluginName)) { $this->logSection('sympal', '...could not download plugin via PEAR', null, 'ERROR'); $success = false; } else { $success = true; } } catch (Exception $e) { $success = false; $this->logSection('sympal', '...exception thrown while downloading from PEAR: ' . $e->getMessage(), null, 'ERROR'); } if (!$success) { $this->logSection('sympal', 'Could not download plugin via PEAR! Trying alternative sources.'); $path = sfSympalPluginToolkit::getPluginDownloadPath($this->_pluginName); if (is_dir($path)) { $this->logSection('sympal', sprintf('...copying plugin from local directory: "%s"', $path)); $this->_filesystem->mirror($path, sfConfig::get('sf_plugins_dir') . '/' . $this->_pluginName, sfFinder::type('dir')); $this->_filesystem->mirror($path, sfConfig::get('sf_plugins_dir') . '/' . $this->_pluginName, sfFinder::type('files')); } else { $this->logSection('sympal', sprintf('...checking out plugin from SVN repository: "%s"', $path)); $svn = exec('which svn'); $this->_filesystem->execute($svn . ' co ' . $path . ' ' . sfConfig::get('sf_plugins_dir') . '/' . $this->_pluginName); } } }