Author: Jonathan.Wage
Date: 2010-02-12 22:52:53 +0100 (Fri, 12 Feb 2010)
New Revision: 27988
Modified:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalInstallPlugin/lib/sfSympalInstall.class.php
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalInstallPlugin/lib/task/sfSympalInstallTask.class.php
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalInstallPlugin/modules/sympal_install/lib/Basesympal_installActions.class.php
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalPluginManagerPlugin/lib/manager/sfSympalPluginManager.class.php
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalPluginManagerPlugin/lib/manager/sfSympalPluginManagerInstall.class.php
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/sfSympalContentActionLoader.class.php
Log:
[1.4][sfSympalPlugin][1.0] More configuration options for install and speeding
things up a bit
Modified:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalInstallPlugin/lib/sfSympalInstall.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalInstallPlugin/lib/sfSympalInstall.class.php
2010-02-12 21:07:43 UTC (rev 27987)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalInstallPlugin/lib/sfSympalInstall.class.php
2010-02-12 21:52:53 UTC (rev 27988)
@@ -7,7 +7,10 @@
$_dispatcher,
$_formatter,
$_application = 'sympal',
- $_forceReinstall = false,
+ $_options = array(
+ 'force_reinstall' => false,
+ 'build_classes' => true
+ ),
$_params = array(
'db_dsn' => null,
'db_username' => null,
@@ -30,6 +33,26 @@
}
}
+ public function getOption($key)
+ {
+ return $this->_options[$key];
+ }
+
+ public function getOptions()
+ {
+ return $this->_options;
+ }
+
+ public function setOption($key, $value)
+ {
+ $this->_options[$key] = $value;
+ }
+
+ public function setOptions(array $options)
+ {
+ $this->_options = $options;
+ }
+
public function setApplication($application)
{
$this->_application = $application;
@@ -60,11 +83,6 @@
$this->_params = $params;
}
- public function setForceReinstall($bool)
- {
- $this->_forceReinstall = $bool;
- }
-
public function logSection($section, $message, $size = null, $style = 'INFO')
{
$this->_configuration->getEventDispatcher()->notify(new sfEvent($this,
'command.log', array($this->_formatter->formatSection($section, $message,
$size, $style))));
@@ -80,49 +98,34 @@
sfSympalConfig::set('installing', true);
- // Prepare the installation parameters
+ $this->_createWebCacheDirectory();
$this->_prepareParams();
- // Build all classes
- $this->_buildAllClasses();
+ 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->_forceReinstall)
+ if (!$dbExists || $this->getOption('force_reinstall'))
{
- // Setup/create the Sympal database
$this->_setupDatabase();
-
- // Install Sympal to the database
- $this->_installSympal();
-
- // Run installation procss for any addon plugins
+ $this->_loadData();
+ $this->_createSite();
$this->_installAddonPlugins();
-
- // Execute post install execute
$this->_executePostInstallSql();
+ $this->_executePostInstallHooks();
+ $this->_publishAssets();
+ $this->_clearCache();
+ $this->_primeCache();
- // Execute post install hooks
- $this->_executePostInstallHooks();
- // If db exists and site does not exist then lets create the site
- } else if ($dbExists && !$this->checkSympalSiteExists()) {
- $this->_createSite();
// Delete site and recreate it
} else {
Doctrine_Manager::connection()->execute('delete from sf_sympal_site
where slug = ?', array($this->_application));
$this->_createSite();
- }
-
- if (!$dbExists || $this->_forceReinstall)
- {
- // Publish plugin assets
- $this->_publishAssets();
-
- // Clear the cache
$this->_clearCache();
-
- // Prime the cache
$this->_primeCache();
}
@@ -132,10 +135,16 @@
$this->_dispatcher->notify(new sfEvent($this, 'sympal.post_install',
array('configuration' => $this->_configuration, 'dispatcher' =>
$this->_dispatcher, 'formatter' => $this->_formatter)));
- if (!$dbExists || $this->_forceReinstall)
+ // Run fix permissions to ensure a 100% ready to go environment
+ $this->_fixPerms();
+ }
+
+ protected function _createWebCacheDirectory()
+ {
+ $dir = sfConfig::get('sf_web_dir').'/cache';
+ if (!is_dir($dir))
{
- // Run fix permissions to ensure a 100% ready to go environment
- $this->_fixPerms();
+ mkdir($dir, 0777, true);
}
}
@@ -178,7 +187,7 @@
return $return;
}
- private function _createSite()
+ protected function _createSite()
{
chdir(sfConfig::get('sf_root_dir'));
$task = new sfSympalCreateSiteTask($this->_dispatcher, $this->_formatter);
@@ -228,6 +237,20 @@
}
}
+ sfSympalConfig::set('site_slug', $this->_application);
+ $task = new sfDoctrineBuildTask($this->_dispatcher, $this->_formatter);
+ $options = array(
+ 'db' => true,
+ 'no-confirmation' => true,
+ 'and-load' => false,
+ 'application' => $this->_application
+ );
+
+ $task->run(array(), $options);
+ }
+
+ protected function _getDataFixtures()
+ {
$path = sfConfig::get('sf_data_dir').'/fixtures/install';
if (is_dir($path))
{
@@ -238,37 +261,21 @@
} else {
$fixtures = true;
}
+ return $fixtures;
+ }
+ protected function _loadData($append = true)
+ {
sfSympalConfig::set('site_slug', $this->_application);
- $task = new sfDoctrineBuildTask($this->_dispatcher, $this->_formatter);
- $options = array(
- 'all' => true,
- 'no-confirmation' => true,
- 'and-load' => $fixtures,
- 'application' => $this->_application
- );
-
- $task->run(array(), $options);
- }
-
- /**
- * Method called in a fresh install or a force reload install
- *
- * This method simply calls the sympal:create-site task and creates
- * a cache directory to store the minified css and js
- */
- protected function _installSympal()
- {
- $task = new sfSympalCreateSiteTask($this->_dispatcher, $this->_formatter);
- $task->run(array('application' => $this->_application),
array('no-confirmation' => true));
-
- $dir = sfConfig::get('sf_web_dir').'/cache';
- if (!is_dir($dir))
+ $task = new sfDoctrineDataLoadTask($this->_dispatcher, $this->_formatter);
+ $fixtures = $this->_getDataFixtures();
+ if (!is_array($fixtures))
{
- mkdir($dir, 0777, true);
+ $fixtures = array();
}
+ $task->run($fixtures, array('append' => $append, 'application' =>
$this->_application));
}
-
+
protected function _installAddonPlugins()
{
$this->logSection('sympal', '...installing addon plugins', null,
'COMMENT');
@@ -277,7 +284,19 @@
foreach ($plugins as $plugin)
{
$manager = sfSympalPluginManager::getActionInstance($plugin, 'install',
$this->_configuration, $this->_formatter);
+
+ // Don't need to publish assets, sympal install does this at the end
$manager->setOption('publish_assets', false);
+
+ // Don't need to clear cache, sympal install does this at the end
+ $manager->setOption('clear_cache', false);
+
+ // Don't need to uninstall first on sympal install
+ $manager->setOption('uninstall_first', false);
+
+ // Don't need to create tables as the sympal install already did this
+ $manager->setOption('create_tables', false);
+
$manager->install();
}
}
Modified:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalInstallPlugin/lib/task/sfSympalInstallTask.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalInstallPlugin/lib/task/sfSympalInstallTask.class.php
2010-02-12 21:07:43 UTC (rev 27987)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalInstallPlugin/lib/task/sfSympalInstallTask.class.php
2010-02-12 21:52:53 UTC (rev 27988)
@@ -19,6 +19,7 @@
new sfCommandOption('db-password', null,
sfCommandOption::PARAMETER_OPTIONAL, 'The database password.'),
new sfCommandOption('no-confirmation', null,
sfCommandOption::PARAMETER_NONE, 'Do not ask for confirmation'),
new sfCommandOption('force-reinstall', null,
sfCommandOption::PARAMETER_NONE, 'Force re-installation'),
+ new sfCommandOption('build-classes', null,
sfCommandOption::PARAMETER_OPTIONAL, 'Build all classes', true),
new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED,
'The environment', 'dev'),
));
@@ -110,9 +111,9 @@
}
if (isset($options['force-reinstall']) && $options['force-reinstall'])
{
- $install->setForceReinstall(true);
+ $install->setOption('force_reinstall', true);
}
-
+ $install->setOption('build_classes', (bool) $options['build-classes']);
$install->install();
$this->log(null);
Modified:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalInstallPlugin/modules/sympal_install/lib/Basesympal_installActions.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalInstallPlugin/modules/sympal_install/lib/Basesympal_installActions.class.php
2010-02-12 21:07:43 UTC (rev 27987)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalInstallPlugin/modules/sympal_install/lib/Basesympal_installActions.class.php
2010-02-12 21:52:53 UTC (rev 27988)
@@ -77,7 +77,7 @@
chdir(sfConfig::get('sf_root_dir'));
$install = new
sfSympalInstall($this->getContext()->getConfiguration(),
$this->getContext()->getEventDispatcher(), $formatter);
$install->setParams($params);
- $install->setForceReinstall(true);
+ $install->setOption('force_reinstall', true);
$install->install();
} catch (Exception $e) {
$this->getUser()->setFlash('error', $e->getMessage());
Modified:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalPluginManagerPlugin/lib/manager/sfSympalPluginManager.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalPluginManagerPlugin/lib/manager/sfSympalPluginManager.class.php
2010-02-12 21:07:43 UTC (rev 27987)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalPluginManagerPlugin/lib/manager/sfSympalPluginManager.class.php
2010-02-12 21:52:53 UTC (rev 27988)
@@ -144,10 +144,23 @@
throw new InvalidArgumentException('Invalid ContentType');
}
+ $superAdmin =
Doctrine_Core::getTable(sfSympalConfig::get('user_model'))->findOneByIsSuperAdmin(1);
+ if (!$superAdmin)
+ {
+ throw new sfException('Could not find a super admin user');
+ }
+
+ $siteSlug = sfConfig::get('app_sympal_config_site_slug',
sfConfig::get('sf_app'));
+ $site = Doctrine_Core::getTable('sfSympalSite')->findOneBySlug($siteSlug);
+ if (!$site)
+ {
+ throw new sfException(sprintf('Could not find site with slug "%s"',
$siteSlug));
+ }
+
$content = new sfSympalContent();
$content->Type = $contentType;
- $content->CreatedBy =
Doctrine_Core::getTable(sfSympalConfig::get('user_model'))->findOneByIsSuperAdmin(1);
- $content->Site =
Doctrine_Core::getTable('sfSympalSite')->findOneBySlug(sfConfig::get('app_sympal_config_site_slug',
sfConfig::get('sf_app')));
+ $content->CreatedBy = $superAdmin;
+ $content->Site = $site;
$content->date_published = new Doctrine_Expression('NOW()');
$name = $contentType['name'];
Modified:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalPluginManagerPlugin/lib/manager/sfSympalPluginManagerInstall.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalPluginManagerPlugin/lib/manager/sfSympalPluginManagerInstall.class.php
2010-02-12 21:07:43 UTC (rev 27987)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalPluginManagerPlugin/lib/manager/sfSympalPluginManagerInstall.class.php
2010-02-12 21:52:53 UTC (rev 27988)
@@ -6,7 +6,8 @@
'create_tables' => true,
'load_data' => true,
'publish_assets' => true,
- 'uninstall_first' => true
+ 'uninstall_first' => true,
+ 'clear_cache' => true
);
public function install()
@@ -36,7 +37,10 @@
$this->_publishAssets();
}
- $this->_clearCache();
+ if ($this->getOption('clear_cache'))
+ {
+ $this->_clearCache();
+ }
sfSympalConfig::writeSetting($this->_pluginName, 'installed', true);
} catch (Exception $e) {
@@ -77,15 +81,6 @@
protected function _loadData()
{
- $installFixtures =
$this->_pluginConfig->getRootDir().'/data/fixtures/install';
- if (is_dir($installFixtures))
- {
- $this->logSection('sympal', sprintf('...loading plugin installation data
fixtures from: "%s"', $installFixtures), null, 'COMMENT');
-
- $task = new sfDoctrineDataLoadTask($this->_dispatcher,
$this->_formatter);
- $task->run(array($installFixtures), array('application' =>
sfConfig::get('sf_app')));
- }
-
$installVars = array();
if ($this->_contentTypeName)
Modified:
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/sfSympalContentActionLoader.class.php
===================================================================
---
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/sfSympalContentActionLoader.class.php
2010-02-12 21:07:43 UTC (rev 27987)
+++
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/sfSympalContentActionLoader.class.php
2010-02-12 21:52:53 UTC (rev 27988)
@@ -45,8 +45,8 @@
public function loadContent()
{
$content = $this->getContent();
+ $this->_handleForward404($content);
$this->_handleIsPublished($content);
- $this->_handleForward404($content);
$this->_user->checkContentSecurity($content);
$this->_loadMetaData($this->_response);
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.