public function install() { if ($this->getOption('uninstall_first')) { $uninstall = new sfSympalPluginManagerUninstall($this->_pluginName, $this->_configuration, $this->_formatter); $uninstall->setOption('publish_assets', false); $uninstall->uninstall(); } $this->logSection('sympal', sprintf('Installing Sympal plugin named "%s"', $this->_pluginName)); try { if ($this->getOption('create_tables')) { $this->_createDatabaseTables(); } if ($this->getOption('load_data')) { $this->_loadData(); } if ($this->getOption('publish_assets')) { $this->_publishAssets(); } if ($this->getOption('clear_cache')) { $this->_clearCache(); } sfSympalConfig::writeSetting($this->_pluginName, 'installed', true); } catch (Exception $e) { $uninstall = new sfSympalPluginManagerUninstall($this->_pluginName, $this->_configuration); $uninstall->uninstall(); throw $e; } }
public function uninstall($delete = null) { if ($delete !== null) { $this->setOption('delete_plugin_files', $delete); } $this->logSection('sympal', sprintf('Uninstalling Sympal plugin named "%s"', $this->_pluginName)); if ($this->hasModels()) { if ($this->getOption('build_all_classes')) { $this->_buildAllClasses(); } if ($this->getOption('delete_related_data')) { $this->_deleteRelatedData(); } if ($this->getOption('delete_other_data')) { $this->_deleteOtherData(); } if ($this->getOption('drop_database_tables')) { $this->_dropDatabaseTables(); } } if ($this->getOption('run_custom_install')) { $this->_runCustomUninstall(); } if ($this->getOption('delete_plugin_files')) { $this->_deletePluginFiles(); } if ($this->getOption('publish_assets')) { $this->_publishAssets(); } $this->_clearCache(); sfSympalConfig::writeSetting($this->_pluginName, 'installed', false); }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { foreach ($arguments['configure'] as $value) { list($key, $value) = explode('=', $value); $e = explode('.', $key); $group = isset($e[1]) ? $e[0] : null; $key = isset($e[1]) ? $e[1] : $e[0]; $value = is_numeric($value) ? (int) $value : $value; $value = $value == 'false' ? false : $value; $value = $value == 'true' ? true : $value; $infoValue = $value; if (in_array(substr($value, 0, 1), array('[', '{'))) { $value = sfYamlInline::load($value); $infoValue = 'YAML: ' . $infoValue; } $writeToApp = isset($options['application']) && $options['application'] ? true : false; if ($group) { $this->logSection('sympal', sprintf('Writing setting "%s" with a value of "%s" under the "%s" group.', $key, $infoValue, $group)); sfSympalConfig::writeSetting($group, $key, $value, $writeToApp); } else { $this->logSection('sympal', sprintf('Writing setting "%s" with a value of "%s".', $key, $infoValue, $group)); sfSympalConfig::writeSetting($key, $value, null, $writeToApp); } } }
public function upgrade() { $result = parent::upgrade(); $versionHistory = sfSympalConfig::get('upgrade_version_history', null, array()); $versionHistory[] = $this->_version . '__' . $this->_number; sfSympalConfig::writeSetting('upgrade_version_history', $versionHistory); return $result; }
/** * Actually runs the installation - this is the main entry point for * installing sympal */ public function install() { // set params as sfConfig variables for global access $this->_prepareParams(); // throw a sympal.pre_install event $this->_dispatcher->notify(new sfEvent($this, 'sympal.pre_install', array('configuration' => $this->_configuration, 'dispatcher' => $this->_dispatcher, 'formatter' => $this->_formatter))); // The main installation stream $tasks = array('_setupDatabase', '_buildAllClasses', '_copyFixtures', '_createSite', '_loadData', '_installAddonPlugins', '_executePostInstallSql', '_executePostInstallHooks', '_publishAssets', '_clearCache', '_primeCache'); foreach ($tasks as $task) { $this->logBlank(); $this->{$task}(); } sfSympalConfig::writeSetting('installed', true); sfSympalConfig::writeSetting('current_version', sfSympalPluginConfiguration::VERSION); $this->_dispatcher->notify(new sfEvent($this, 'sympal.post_install', array('configuration' => $this->_configuration, 'dispatcher' => $this->_dispatcher, 'formatter' => $this->_formatter))); // Run fix permissions to ensure a 100% ready to go environment $this->_fixPerms(); }
public function executeMake_default(sfWebRequest $request) { $theme = $request->getParameter('name'); if ($request->getParameter('site')) { $site = $this->getSympalContext()->getService('site_manager')->getSite(); $this->askConfirmation(__('Are you sure?'), sprintf(__('This action will change the default theme to "%s" for the "%s" site.'), $theme, $site->getTitle())); if ($site->getTheme() == $theme) { $site->setTheme(null); } else { $site->setTheme($theme); } $site->save(); } else { $this->askConfirmation(__('Are you sure?'), sprintf(__('This action will change the global default theme to "%s"'), $theme)); sfSympalConfig::writeSetting('theme', 'default_theme', $theme); } $this->clearCache(); $this->getUser()->setFlash('notice', __('Theme successfully changed!')); $this->redirect('@sympal_themes'); }
<?php $app = 'sympal'; require_once dirname(__FILE__) . '/../../bootstrap/unit.php'; $t = new lime_test(6); sfSympalConfig::set('test', true); $t->is(sfSympalConfig::get('test'), true, '->get() works with just one argument'); sfSympalConfig::set('group', 'test', true); $t->is(sfSympalConfig::get('group', 'test'), true, '->get() works using the group arugment'); $t->is(sfSympalConfig::get('doesnt_exists', null, 'default_value'), 'default_value', '->get() returns a default value if the key does not exist'); sfSympalConfig::writeSetting('test_write_value', 1); $path = sfConfig::get('sf_config_dir') . '/app.yml'; $array = (array) sfYaml::load(file_get_contents($path)); $t->is(isset($array['all']['sympal_config']['test_write_value']), true, '->writeSetting() writes out correctly to the config/app.yml file'); $t->is(sfSympalConfig::isI18nEnabled(), false, '->isI18nEnabled() correctly returns false'); $t->is(sfSympalConfig::isI18nEnabled('sfSympalContent'), false, '->isI18nEnabled($modelName) correctly returns false');
/** * Runs the upgrade and then writes the latest version to config */ protected function _doUpgrade() { parent::_doUpgrade(); sfSympalConfig::writeSetting('current_version', $this->getLatestVersion()); }
<?php if (!isset($app)) { $app = 'sympal'; } require_once dirname(__FILE__) . '/../fixtures/project/config/ProjectConfiguration.class.php'; $configuration = ProjectConfiguration::getApplicationConfiguration($app, 'test', isset($debug) ? $debug : true); require_once dirname(__FILE__) . '/../bootstrap/cleanup.php'; sfSympalConfig::writeSetting('installed', false); sfContext::createInstance($configuration); $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->get('/install'); $install = array('install' => array('user' => array('first_name' => 'Jonathan', 'last_name' => 'Wage', 'email_address' => '*****@*****.**', 'username' => 'jwage', 'password' => 'changeme', 'password_again' => 'changeme'))); $browser->click('Install Now', $install)->with('response')->begin()->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'sympal_dashboard')->end()->with('user')->begin()->isAuthenticated()->end(); sfSympalConfig::writeSetting('installed', true);
/** * Actually runs the installation - this is the main entry point for * installing sympal */ public function install() { $this->_dispatcher->notify(new sfEvent($this, 'sympal.pre_install', array('configuration' => $this->_configuration, 'dispatcher' => $this->_dispatcher, 'formatter' => $this->_formatter))); sfSympalConfig::set('installing', true); $this->_createWebCacheDirectory(); $this->_prepareParams(); if ($this->getOption('build_classes')) { $this->_buildAllClasses(); } $dbExists = $this->checkSympalDatabaseExists(); // If database does not exist or we are forcing a reinstall then lets do a full install if (!$dbExists || $this->getOption('force_reinstall')) { $this->_setupDatabase(); $this->_loadData(); $this->_createSite(); $this->_installAddonPlugins(); $this->_executePostInstallSql(); $this->_executePostInstallHooks(); $this->_publishAssets(); $this->_clearCache(); $this->_primeCache(); // Delete site and recreate it } else { Doctrine_Manager::connection()->execute('delete from sf_sympal_site where slug = ?', array($this->_application)); $this->_createSite(); $this->_clearCache(); $this->_primeCache(); } sfSympalConfig::writeSetting('installed', true); sfSympalConfig::set('installing', false); sfSympalConfig::writeSetting('current_version', sfSympalPluginConfiguration::VERSION); $this->_dispatcher->notify(new sfEvent($this, 'sympal.post_install', array('configuration' => $this->_configuration, 'dispatcher' => $this->_dispatcher, 'formatter' => $this->_formatter))); // Run fix permissions to ensure a 100% ready to go environment $this->_fixPerms(); }
<?php require_once dirname(__FILE__) . '/../bootstrap/functional.php'; $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->signInAsAdmin(); $browser->get('/admin/configuration')->click('Save', array('settings' => array('breadcrumbs_separator' => ' / ', 'plugin_api' => array('username' => 'test', 'password' => 'test')))); $after = sfYaml::load(sfConfig::get('sf_app_dir') . '/config/app.yml'); $t = $browser->test(); $t->is($after['all']['sympal_config']['breadcrumbs_separator'], ' / ', 'Test breadcrumbs separator saved'); $t->is($after['all']['sympal_config']['plugin_api']['username'], 'test', 'Test plugin_api.username saved'); $t->is($after['all']['sympal_config']['plugin_api']['password'], 'test', 'Test plugin_api.password saved'); sfSympalConfig::writeSetting('breadcrumbs_separator', ' / ');