protected function execute($arguments = array(), $options = array()) { if (!isset($options['origin'])) { $options['origin'] = '2.12'; } if (!in_array($options['origin'], array('2.12', '2.14', '3.4'))) { throw new RuntimeException('You must specify "2.12", "2.14" or "3.4" to the --origin option. (--origin オプションには 2.12、 2.14 または 3.4 を指定してください。)'); } sfConfig::set('op_upgrade2_version', $options['origin']); $op2config = sfConfig::get('sf_config_dir') . DIRECTORY_SEPARATOR . 'config.OpenPNE2.php'; if (!is_readable($op2config)) { throw new RuntimeException('You must copy the config.php in your OpenPNE2 as config/config.OpenPNE2.php. (お使いの OpenPNE2 の config.php を config/config.OpenPNE2.php としてコピーしてください。)'); } if (!defined('OPENPNE_DIR')) { define('OPENPNE_DIR', sfConfig::get('sf_root_dir')); } require_once $op2config; $this->runTask('configure:database', array(opToolkit::createStringDsnFromArray($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']), $GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['username'], empty($GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['password']) ? null : $GLOBALS['_OPENPNE_DSN_LIST']['main']['dsn']['password'])); $path = sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'upgrade' . DIRECTORY_SEPARATOR . '2'; $upgrader = new opUpgrader($this->dispatcher, $this->formatter, $path, $this->configuration); if ($options['rules']) { $upgrader->setOption('targets', $options['rules']); } if ('3.4' === $options['origin']) { $upgrader->setDefinitionName('definition-34to36.yml'); } $this->logSection('upgrade', 'Begin upgrading from 2.x'); $upgrader->execute(); $task = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter); $task->run(array(), array()); }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { // remove lib/symfony and data/symfony directories if (!is_dir('lib/symfony')) { throw new sfCommandException('You can unfreeze only if you froze the symfony libraries before.'); } // change symfony path in ProjectConfiguration.class.php $config = sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php'; $content = file_get_contents($config); if (preg_match('/^# FROZEN_SF_LIB_DIR\\: (.+?)$/m', $content, $match)) { $publishAssets = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter); $publishAssets->setCommandApplication($this->commandApplication); $symfonyLibDir = $match[1]; $content = str_replace("# FROZEN_SF_LIB_DIR: {$match[1]}\n\n", '', $content); // need to escape windows pathes "symfony\1.2" -> "symfony\\1.2" // because preg_replace would then use \1 as group identifier resulting in "symfony.2" $content = preg_replace('#^require_once.+?$#m', sprintf("require_once '%s/autoload/sfCoreAutoload.class.php';", str_replace('\\', '\\\\', $symfonyLibDir)), $content, 1); file_put_contents($config, $content); // re-publish assets $publishAssets->run(array(), array('--symfony-lib-dir=' . $symfonyLibDir)); // remove files $finder = sfFinder::type('any'); $this->getFilesystem()->remove($finder->in(sfConfig::get('sf_lib_dir') . '/symfony')); $this->getFilesystem()->remove(sfConfig::get('sf_lib_dir') . '/symfony'); $this->getFilesystem()->remove($finder->in(sfConfig::get('sf_data_dir') . '/symfony')); $this->getFilesystem()->remove(sfConfig::get('sf_data_dir') . '/symfony'); $this->getFilesystem()->remove($finder->in(sfConfig::get('sf_web_dir') . '/sf')); $this->getFilesystem()->remove(sfConfig::get('sf_web_dir') . '/sf'); } }
protected function execute($arguments = array(), $options = array()) { // execute ./symfony doctrine:data-load $sfDoctrineDataLoadTask = new sfDoctrineDataLoadTask($this->dispatcher, $this->formatter); $sfDoctrineDataLoadTask->run($arguments = array('./plugins/opTimelinePlugin/data/fixtures/010_gadget_setting.yml'), $options = array('append')); // execute ./symfony plugin:publish-assets $sfPluginPublishAssetsTask = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter); $sfPluginPublishAssetsTask->run(); // execute ./symfomy cc $sfCacheClearTask = new sfCacheClearTask($this->dispatcher, $this->formatter); $sfCacheClearTask->run($arguments = array(), $options = array('type' => 'all')); }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { parent::execute($arguments, $options); $projectWebPath = sfConfig::get('sf_web_dir'); $filesystem = new dmFilesystem($this->dispatcher, $this->formatter); foreach (array('dmAdminPlugin', 'dmFrontPlugin') as $plugin) { $this->logSection('plugin', 'Configuring plugin - ' . $plugin); $this->installPluginAssets($plugin, dm::getDir() . '/' . $plugin); } // remove useless doctrine assets if (is_readable($doctrineAssetPath = dmOs::join($projectWebPath, 'sfDoctrinePlugin'))) { if (!is_link($doctrineAssetPath)) { $filesystem->deleteDirContent($doctrineAssetPath); } $filesystem->remove($doctrineAssetPath); } // remove web cache dir $webCacheDir = sfConfig::get('sf_web_dir') . '/cache'; if (is_link($webCacheDir)) { $filesystem->remove($webCacheDir); } // create web cache dir $filesystem->mkdir($webCacheDir); if (!file_exists(dmOs::join($projectWebPath, 'sf'))) { $filesystem->relativeSymlink(realpath(sfConfig::get('sf_symfony_lib_dir') . '/../data/web/sf'), dmOs::join($projectWebPath, 'sf'), true); } }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { // check that the symfony librairies are not already freeze for this project if (is_readable(sfConfig::get('sf_lib_dir') . '/symfony')) { throw new sfCommandException('You can only freeze when lib/symfony is empty.'); } if (is_readable(sfConfig::get('sf_data_dir') . '/symfony')) { throw new sfCommandException('You can only freeze when data/symfony is empty.'); } if (is_readable(sfConfig::get('sf_web_dir') . '/sf')) { throw new sfCommandException('You can only freeze when web/sf is empty.'); } if (is_link(sfConfig::get('sf_web_dir') . '/sf')) { $this->getFilesystem()->remove(sfConfig::get('sf_web_dir') . '/sf'); } $symfonyLibDir = sfConfig::get('sf_symfony_lib_dir'); $symfonyDataDir = $arguments['symfony_data_dir']; if (!is_readable($symfonyDataDir)) { throw new sfCommandException(sprintf('The symfony data dir does not seem to be located at "%s".', $symfonyDataDir)); } $this->logSection('freeze', sprintf('freezing lib found in "%s"', $symfonyLibDir)); $this->logSection('freeze', sprintf('freezing data found in "%s"', $symfonyDataDir)); $this->getFilesystem()->mkdirs('lib' . DIRECTORY_SEPARATOR . 'symfony'); $this->getFilesystem()->mkdirs('data' . DIRECTORY_SEPARATOR . 'symfony'); $finder = sfFinder::type('any')->exec(array($this, 'excludeTests')); $this->getFilesystem()->mirror($symfonyLibDir, sfConfig::get('sf_lib_dir') . '/symfony', $finder); $this->getFilesystem()->mirror($symfonyDataDir, sfConfig::get('sf_data_dir') . '/symfony', $finder); $this->getFilesystem()->rename(sfConfig::get('sf_data_dir') . '/symfony/web/sf', sfConfig::get('sf_web_dir') . '/sf'); $publishAssets = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter); $publishAssets->setCommandApplication($this->commandApplication); // change symfony path in ProjectConfiguration.class.php $config = sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php'; $content = file_get_contents($config); $content = str_replace('<?php', "<?php\n\n# FROZEN_SF_LIB_DIR: {$symfonyLibDir}", $content); $content = preg_replace('#(\'|")' . preg_quote($symfonyLibDir, '#') . '#', "dirname(__FILE__).\$1/../lib/symfony", $content); file_put_contents($config, $content); // re-publish assets $publishAssets->run(array(), array('--symfony-lib-dir=' . sfConfig::get('sf_lib_dir') . '/symfony')); }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { if (file_exists('symfony')) { throw new sfCommandException(sprintf('A project named "%s" already exists in this directory.', $arguments['name'])); } // create basic project structure $finder = sfFinder::type('any')->discard('.sf'); $this->getFilesystem()->mirror(dirname(__FILE__) . '/skeleton/project', sfConfig::get('sf_root_dir'), $finder); // update project name and directory $finder = sfFinder::type('file')->name('properties.ini', 'apache.conf', 'propel.ini', 'databases.yml'); $this->getFileSystem()->replaceTokens($finder->in(sfConfig::get('sf_config_dir')), '##', '##', array('PROJECT_NAME' => $arguments['name'], 'PROJECT_DIR' => sfConfig::get('sf_root_dir'))); // update ProjectConfiguration class $this->getFileSystem()->replaceTokens(sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php', '##', '##', array('SYMFONY_LIB_DIR' => sfConfig::get('sf_symfony_lib_dir'))); // update vhost sample file $this->getFileSystem()->replaceTokens(sfConfig::get('sf_config_dir') . '/vhost.sample', '##', '##', array('PROJECT_NAME' => $arguments['name'], 'SYMFONY_WEB_DIR' => sfConfig::get('sf_web_dir'), 'SYMFONY_SF_DIR' => realpath(sfCoreAutoload::getInstance()->getBaseDir() . '../data/web/sf'))); // fix permission for common directories $fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter); $fixPerms->setCommandApplication($this->commandApplication); $fixPerms->run(); // publish assets for core plugins $publishAssets = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter); $publishAssets->setCommandApplication($this->commandApplication); $publishAssets->run(array(), array('--core-only')); }
protected function publishAssets() { $publishAssets = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter); $publishAssets->run(); }
protected function _publishAssets() { if ($this->hasWebDirectory()) { chdir(sfConfig::get('sf_root_dir')); $assets = new sfPluginPublishAssetsTask($this->_dispatcher, $this->_formatter); $ret = $assets->run(array($this->_pluginName), array()); } }
protected function _publishAssets() { chdir(sfConfig::get('sf_root_dir')); $task = new sfPluginPublishAssetsTask($this->_dispatcher, $this->_formatter); $task->run(); }
public function upgrade() { $publishAssets = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter); $publishAssets->setCommandApplication($this->commandApplication); $publishAssets->run(array(), array('--core-only')); }
protected function execute($arguments = array(), $options = array()) { new sfDatabaseManager($this->configuration); // opening connection @$this->createCacheDirectory(); $oldPluginList = sfFinder::type('dir')->in(sfConfig::get('sf_plugins_dir')); if (!$options['no-update-plugin']) { $this->installPlugins($options['target']); } $newPluginList = sfFinder::type('dir')->name('op*Plugin')->maxdepth(1)->in(sfConfig::get('sf_plugins_dir')); foreach ($oldPluginList as $k => $v) { $pluginName = basename($v); if ((bool) Doctrine::getTable('SnsConfig')->get($pluginName . '_needs_data_load', false)) { // It needs initializing unset($oldPluginList[$k]); } } $installedPlugins = array_map('basename', array_diff($newPluginList, $oldPluginList)); if (!$options['no-build-model']) { $this->buildModel($options); } foreach ($installedPlugins as $v) { $modelDir = sfConfig::get('sf_lib_dir') . '/model/doctrine/' . $v; if (!is_dir($modelDir)) { continue; } Doctrine::createTablesFromModels($modelDir); } if ($options['target']) { $targets = array($options['target']); } else { $targets = array_merge(array('OpenPNE'), $this->getEnabledOpenPNEPlugin()); } $databaseManager = new sfDatabaseManager($this->configuration); foreach ($targets as $target) { if (in_array($target, $installedPlugins)) { continue; } try { $this->migrateFromScript($target, $databaseManager); } catch (Doctrine_Migration_Exception $e) { if ('OpenPNE' === $target) { throw $e; } $errorText = ''; $errors = array(); preg_match_all('/Error #[0-9]+ \\- .*$/m', $e->getMessage(), $errors, PREG_SET_ORDER); foreach ($errors as $error) { $errorText .= $error[0] . "\n"; } $e = new Exception(sprintf("migrating of %s encountered the following errors:\n %s", $target, $errorText)); $this->commandApplication->renderException($e); } } $targets = array_merge($targets, $installedPlugins); foreach ($targets as $target) { $this->dataLoadForInitializePlugin($target); } if ($this->migrationException) { throw $this->migrationException; } $task = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter); $task->run(array(), array()); }
protected function _publishAssets() { chdir(sfConfig::get('sf_root_dir')); $task = new sfPluginPublishAssetsTask($this->_dispatcher, $this->_formatter); $this->logTaskCall('plugins', 'Creating plugin symlinks', 'plugin:publish-assets'); $this->_disableOutput(); $task->run(); $this->_enableOutput(); }
protected function execute($arguments = array(), $options = array()) { $name = $arguments['name']; $pluginName = 'sfSympal' . Doctrine_Inflector::classify(Doctrine_Inflector::tableize($name)) . 'Plugin'; $path = sfConfig::get('sf_plugins_dir') . '/' . $pluginName; if (!$options['no-confirmation'] && !$this->askConfirmation(array('This command will create a new plugin named ' . $pluginName, 'Are you sure you want to proceed? (y/N)'), 'QUESTION_LARGE', false)) { $this->logSection('sympal', 'Plugin creation aborted'); return 1; } if (is_dir($path)) { if (isset($options['re-generate']) && $options['re-generate']) { $uninstall = new sfSympalPluginUninstallTask($this->dispatcher, $this->formatter); $uninstall->setCommandApplication($this->commandApplication); $uninstallOptions = array(); $uninstallOptions[] = '--delete'; $uninstallOptions[] = '--no-confirmation'; $ret = $uninstall->run(array($name), $uninstallOptions); } else { throw new sfException('A plugin with the name ' . $pluginName . ' already exists!'); } } if (is_dir($path)) { Doctrine_Lib::removeDirectories($path); } $generatePlugin = new sfGeneratePluginTask($this->dispatcher, $this->formatter); $generatePlugin->setCommandApplication($this->commandApplication); $generatePluginOptions = array(); if (isset($options['module']) && !empty($options['module'])) { $generatePluginOptions[] = '--module=' . implode(' --module=', $options['module']); } if (isset($options['test-application'])) { $generatePluginOptions[] = '--test-application=' . $options['test-application']; } if (isset($options['skip-test-dir'])) { $generatePluginOptions[] = '--skip-test-dir'; } $generatePlugin->run(array($pluginName), $generatePluginOptions); $contentType = isset($options['content-type']) ? $options['content-type'] : null; $slug = str_replace('-', '_', Doctrine_Inflector::urlize($name)); $lowerName = str_replace('-', '_', $slug); if ($contentType) { $pluginYamlSchema = <<<EOF --- {$contentType}: actAs: [sfSympalContentTypeTemplate] columns: title: string(255) body: clob EOF; $pluginInstallDataFixtures = <<<EOF # {$pluginName} install data fixtures sfSympalContentType: content_type_{$lowerName}: name: {$contentType} slug: {$slug} description: {$lowerName} content type label: {$lowerName} content type default_path: /{$lowerName}/:slug EOF; } $itemsToCreate = array('config' => null, 'config/doctrine' => null, 'config/routing.yml' => '# ' . $pluginName . ' routing', 'data' => null); if (isset($pluginInstallDataFixtures)) { $itemsToCreate['data/fixtures'] = null; $itemsToCreate['data/fixtures/' . $contentType . '.yml'] = $pluginInstallDataFixtures; } if (isset($pluginYamlSchema)) { $itemsToCreate['config/doctrine/schema.yml'] = $pluginYamlSchema; } $appYaml = ''; if (isset($options['theme'])) { $appYaml .= sprintf('all: theme: themes: %s: layout: %s stylesheets: - %s', $options['theme'], $options['theme'], '/' . $pluginName . '/css/' . $options['theme'] . '.css'); $itemsToCreate['templates/' . $options['theme'] . '.php'] = file_get_contents($this->configuration->getPluginConfiguration('sfSympalPlugin')->getRootDir() . '/templates/default.php'); $itemsToCreate['web/css/' . $options['theme'] . '.css'] = file_get_contents($this->configuration->getPluginConfiguration('sfSympalPlugin')->getRootDir() . '/web/themes/default/css/main.css'); } if ($contentType) { $appYaml .= sprintf('all: sympal_config: content_types: %s: content_templates: default_view: template: %s/view', $contentType, $contentType); $itemsToCreate['modules'] = null; $itemsToCreate['modules/' . $contentType] = null; $itemsToCreate['modules/' . $contentType . '/templates'] = null; $itemsToCreate['modules/' . $contentType . '/templates/_view.php'] = "<?php echo get_sympal_content_slot(\$content, 'title') ?>"; } if ($appYaml) { $itemsToCreate['config/app.yml'] = $appYaml; } foreach ($itemsToCreate as $item => $value) { $itemPath = $path . '/' . $item; if (!is_null($value)) { $dir = dirname($itemPath); $this->getFilesystem()->mkdirs($dir); file_put_contents($itemPath, $value); } else { $this->getFilesystem()->mkdirs($itemPath); } } if (isset($options['install']) && $options['install']) { $install = new sfSympalPluginInstallTask($this->dispatcher, $this->formatter); $install->setCommandApplication($this->commandApplication); $installOptions = array(); if (isset($options['content-type'])) { $installOptions[] = '--content-type=' . $options['content-type']; } $ret = $install->run(array($name), $installOptions); } $pluginAssets = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter); $pluginAssets->run(array(), array()); $cc = new sfCacheClearTask($this->dispatcher, $this->formatter); $ret = $cc->run(array(), array()); }