/**
  * Shortcut to the clear cache task from your actions
  *
  * @param array $options 
  * @return void
  */
 public function clearCache(array $options = array())
 {
     chdir(sfConfig::get('sf_root_dir'));
     $task = new sfCacheClearTask($this->getContext()->getEventDispatcher(), new sfFormatter());
     $task->run(array(), $options);
     $this->resetSympalRoutesCache();
 }
 public function run()
 {
     opApplicationConfiguration::unregisterZend();
     $task = new sfDoctrineBuildModelTask(clone $this->options['dispatcher'], clone $this->options['formatter']);
     $task->run(array(), array('application' => 'pc_frontend', 'env' => sfConfig::get('sf_environment', 'prod')));
     $task = new sfCacheClearTask(clone $this->options['dispatcher'], clone $this->options['formatter']);
     $task->run(array(), array('application' => null, 'env' => sfConfig::get('sf_environment', 'prod')));
     opApplicationConfiguration::registerZend();
 }
 public function execute($request)
 {
     $this->form = new sfForm();
     if (!$this->context->user->hasCredential('administrator')) {
         QubitAcl::forwardUnauthorized();
     }
     $criteria = new Criteria();
     $criteria->add(QubitSetting::NAME, 'plugins');
     if (1 == count($query = QubitSetting::get($criteria))) {
         $setting = $query[0];
         $this->form->setDefault('enabled', unserialize($setting->__get('value', array('sourceCulture' => true))));
     }
     $configuration = ProjectConfiguration::getActive();
     $pluginPaths = $configuration->getAllPluginPaths();
     foreach (sfPluginAdminPluginConfiguration::$pluginNames as $name) {
         unset($pluginPaths[$name]);
     }
     $this->plugins = array();
     foreach ($pluginPaths as $name => $path) {
         $className = $name . 'Configuration';
         if (sfConfig::get('sf_plugins_dir') == substr($path, 0, strlen(sfConfig::get('sf_plugins_dir'))) && is_readable($classPath = $path . '/config/' . $className . '.class.php')) {
             $this->installPluginAssets($name, $path);
             require_once $classPath;
             $class = new $className($configuration);
             // Build a list of themes
             if (isset($class::$summary) && 1 === preg_match('/theme/i', $class::$summary)) {
                 $this->plugins[$name] = $class;
             }
         }
     }
     if ($request->isMethod('post')) {
         $this->form->setValidators(array('enabled' => new sfValidatorChoice(array('choices' => array_keys($this->plugins), 'empty_value' => array(), 'multiple' => true))));
         $this->form->bind($request->getPostParameters());
         if ($this->form->isValid()) {
             if (1 != count($query)) {
                 $setting = new QubitSetting();
                 $setting->name = 'plugins';
             }
             $settings = unserialize($setting->__get('value', array('sourceCulture' => true)));
             foreach (array_keys($this->plugins) as $item) {
                 if (in_array($item, (array) $this->form->getValue('enabled'))) {
                     $settings[] = $item;
                 } else {
                     if (false !== ($key = array_search($item, $settings))) {
                         unset($settings[$key]);
                     }
                 }
             }
             $setting->__set('value', serialize(array_unique($settings)));
             $setting->save();
             // Clear cache
             $cacheClear = new sfCacheClearTask(sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
             $cacheClear->run();
             $this->redirect(array('module' => 'sfPluginAdminPlugin', 'action' => 'themes'));
         }
     }
 }
예제 #4
0
 public function save()
 {
     $array = $this->_buildArrayToWrite();
     $this->_path = sfConfig::get('sf_app_dir') . '/config/app.yml';
     file_put_contents($this->_path, sfYaml::dump($array, 4));
     chdir(sfConfig::get('sf_root_dir'));
     $task = new sfCacheClearTask(sfApplicationConfiguration::getActive()->getEventDispatcher(), new sfFormatter());
     $task->run(array(), array('type' => 'config'));
 }
 public function execute($request)
 {
     // Use existing symfony task
     $cacheClear = new sfCacheClearTask(sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
     $cacheClear->run();
     // Clear the search index
     QubitSearch::getInstance()->getEngine()->erase();
     QubitSearch::getInstance()->optimize();
     $this->redirect(array('module' => 'sfInstallPlugin', 'action' => 'finishInstall'));
 }
 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'));
 }
 protected function execute($arguments = array(), $options = array())
 {
     $configuration = $this->createConfiguration('pc_frontend', 'cli');
     $name = $arguments['name'];
     if (!$configuration->isPluginExists($name)) {
         throw new sfException(sprintf('Plugin "%s" does not installed', $name));
     }
     if ($configuration->isDisabledPlugin($name)) {
         throw new sfException(sprintf('Plugin "%s" is already disactivated', $name));
     }
     opPlugin::getInstance($name)->setIsActive(false);
     $cc = new sfCacheClearTask($this->dispatcher, $this->formatter);
     $cc->run();
 }
예제 #8
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $app = $arguments['application'];
     $env = $arguments['env'];
     $lockFile = sfConfig::get('sf_data_dir') . '/' . $app . '_' . $env . '.lck';
     if (!file_exists($lockFile)) {
         $this->logSection('enable', sprintf('%s [%s] is currently ENABLED', $app, $env));
     } else {
         $this->getFilesystem()->remove($lockFile);
         $clearCache = new sfCacheClearTask($this->dispatcher, $this->formatter);
         $clearCache->setCommandApplication($this->commandApplication);
         $clearCache->run(array(), array('--app=' . $app, '--env=' . $env));
         $this->logSection('enable', sprintf('%s [%s] has been ENABLED', $app, $env));
     }
 }
 protected function execute($arguments = array(), $options = array())
 {
     $pluginPath = sfConfig::get('sf_plugins_dir') . '/';
     $file = $pluginPath . 'opLikePlugin/addtags.lock';
     $targetPlugins = array('opTimelinePlugin' => $pluginPath . 'opLikePlugin/lib/task/opTimelinePlugin.sh', 'opDiaryPlugin' => $pluginPath . 'opLikePlugin/lib/task/opDiaryPlugin.sh', 'opCommunityTopicPlugin' => $pluginPath . 'opLikePlugin/lib/task/opCommunityTopicPlugin.sh');
     foreach ($targetPlugins as $key => $value) {
         chmod($value, 0755);
     }
     if (!file_exists($file)) {
         touch($file);
         chmod($file, 0666);
         $this->logSection('opLikePlugin', 'パッチを実行します。');
     } else {
         unlink($file);
         $this->logSection('opLikePlugin', 'リバースパッチを実行します。');
         foreach ($targetPlugins as $key => $value) {
             $targetPlugins[$key] .= ' -R';
         }
     }
     $dirList = array();
     $fileList = scandir($pluginPath);
     foreach ($fileList as $value) {
         if (is_dir($pluginPath . $value) && isset($targetPlugins[$value])) {
             exec($targetPlugins[$value] . ' --dry-run', $tempOutput, $execResult);
             if (0 === $execResult) {
                 exec($targetPlugins[$value], $shOutput);
                 foreach ($shOutput as $output) {
                     echo $output . "\n";
                 }
             } else {
                 $this->logSection('opLikePlugin', 'パッチの適用に失敗しました。');
             }
         }
     }
     // 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())
 {
     if (1 == count($arguments['app']) && !file_exists(sfConfig::get('sf_apps_dir') . '/' . $arguments['app'][0])) {
         // support previous task signature
         $applications = array($arguments['env']);
         $env = $arguments['app'][0];
     } else {
         $applications = count($arguments['app']) ? $arguments['app'] : sfFinder::type('dir')->relative()->maxdepth(0)->in(sfConfig::get('sf_apps_dir'));
         $env = $arguments['env'];
     }
     foreach ($applications as $app) {
         $lockFile = sfConfig::get('sf_data_dir') . '/' . $app . '_' . $env . '.lck';
         if (!file_exists($lockFile)) {
             $this->logSection('enable', sprintf('%s [%s] is currently ENABLED', $app, $env));
         } else {
             $this->getFilesystem()->remove($lockFile);
             $clearCache = new sfCacheClearTask($this->dispatcher, $this->formatter);
             $clearCache->setCommandApplication($this->commandApplication);
             $clearCache->setConfiguration($this->configuration);
             $clearCache->run(array(), array('--app=' . $app, '--env=' . $env));
             $this->logSection('enable', sprintf('%s [%s] has been ENABLED', $app, $env));
         }
     }
 }
예제 #11
0
 protected function installPlugins($target = null)
 {
     if ('OpenPNE' === $target) {
         return null;
     }
     $task = new sfCacheClearTask($this->dispatcher, $this->formatter);
     @$task->run();
     $task = new openpnePermissionTask($this->dispatcher, $this->formatter);
     @$task->run();
     $options = array();
     if ($target) {
         $options[] = '--target=' . $target;
     }
     $task = new opPluginSyncTask($this->dispatcher, $this->formatter);
     $task->run(array(), $options);
 }
예제 #12
0
 /**
  * Shortcut to clear the cache in a task
  *
  * @param array $options 
  * @return void
  */
 public function clearCache(array $options = array())
 {
     $task = new sfCacheClearTask($this->dispatcher, $this->formatter);
     $task->run(array(), $options);
 }
 public function runSymfonyCacheClear()
 {
     $cacheClear = new sfCacheClearTask($this->dispatcher, $this->formatter);
     $cacheClear->run();
 }
 protected function clearCache()
 {
     $cc = new sfCacheClearTask($this->dispatcher, $this->formatter);
     $cc->run();
 }
예제 #15
0
<?php

/**
 * sfTaskExtraBaseTask tests.
 */
include dirname(__FILE__) . '/../../bootstrap/unit.php';
$task = new sfCacheClearTask($configuration->getEventDispatcher(), new sfFormatter());
$task->setConfiguration($configuration);
$t = new lime_test(5);
// ::doCheckPluginExists()
$t->diag('::doCheckPluginExists()');
try {
    sfTaskExtraBaseTask::doCheckPluginExists($task, 'NonexistantPlugin');
    $t->fail('::doCheckPluginExists() throws an exception if the plugin does not exist');
} catch (Exception $e) {
    $t->pass('::doCheckPluginExists() throws an exception if the plugin does not exist');
}
try {
    sfTaskExtraBaseTask::doCheckPluginExists($task, 'NonexistantPlugin', false);
    $t->pass('::doCheckPluginExists() does not throw an excpetion if a plugin does not exists and is passed false');
} catch (Exception $e) {
    $t->fail('::doCheckPluginExists() does not throw an excpetion if a plugin does not exists and is passed false');
    $t->diag('    ' . $e->getMessage());
}
try {
    sfTaskExtraBaseTask::doCheckPluginExists($task, 'StandardPlugin');
    $t->pass('::doCheckPluginExists() does not throw an exception if a plugin exists');
} catch (Exception $e) {
    $t->fail('::doCheckPluginExists() does not throw an exception if a plugin exists');
    $t->diag('    ' . $e->getMessage());
}
예제 #16
0
 protected function _clearCache()
 {
     chdir(sfConfig::get('sf_root_dir'));
     $task = new sfCacheClearTask($this->_dispatcher, $this->_formatter);
     $task->run();
 }
예제 #17
0
 public static function checkSettingsYml($noScriptName)
 {
     $settingsYml = array();
     $settingsYmlPath = sfConfig::get('sf_app_config_dir') . '/settings.yml';
     // Read settings.yml contents from existing settings.yml, settings.yml.tmpl
     // (for a Subversion checkout), or symfony skeleton settings.yml, whichever
     // is found first
     $settingsYmlPaths = array();
     $settingsYmlPaths[] = $settingsYmlPath;
     $settingsYmlPaths[] = $settingsYmlPath . '.tmpl';
     $settingsYmlPaths[] = sfConfig::get('sf_lib_dir') . '/task/generator/skeleton/app/app/config/settings.yml';
     foreach ($settingsYmlPaths as $path) {
         if (false !== ($settingsYmlContents = file_get_contents($path))) {
             break;
         }
     }
     $settingsYmlContents = sfInstall::setNoScriptName($noScriptName, $settingsYmlContents);
     if (false === file_put_contents($settingsYmlPath, $settingsYmlContents)) {
         $settingsYml['notWritable'] = 'notWritable';
     }
     chdir(sfConfig::get('sf_root_dir'));
     // TODO By instantiating a new application configuration the cache clear
     // task may change these settings, leading to bugs in code which expects
     // them to remain constant
     $saveDebug = sfConfig::get('sf_debug');
     $saveLoggingEnabled = sfConfig::get('sf_logging_enabled');
     // TODO We do not want to cache anything during install, but currently we
     // must clear the cache after adding enabling sfInstallPlugin : (
     $cacheClear = new sfCacheClearTask(sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
     $cacheClear->run();
     sfConfig::set('sf_debug', $saveDebug);
     sfConfig::set('sf_logging_enabled', $saveLoggingEnabled);
     return $settingsYml;
 }
예제 #18
0
    /**
     * Create the config file with the database settings and write email settings
     *
     * @param sfWebRequest $request
     * @return <type>
     */
    public function executeSaveData(sfWebRequest $request) {
        $sysObj = new SystemSetting();
        $installer = new Installer();
        $data = $request->getPostParameters();
        $installer->createConfigFile($data); // write settings in database.yml
        // create DB
        $task = new sfDoctrineBuildAllReLoadTask(sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
        chdir(sfConfig::get('sf_root_dir'));
        $task->run(array(),array('--no-confirmation', '--env=all', '--dir='.sfConfig::get('sf_root_dir').'/data/fixtures/'.$data['productive_data'].''));
        $data = $sysObj->buildEmailSetting($data);
        UserLoginTable::instance()->updateEmail($data['productive_emailadresse']);
        EmailConfigurationTable::instance()->updateEmailConfiguration($data);
        // clear cache
        $taskCC = new sfCacheClearTask(sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
        $taskCC->run(array(), array());
        // create JS Cache
        $ccCache = new TemplateCaching();
        $ccCache->checkCacheDir();
        $ccCache->setFiles();
        $lastModified = $ccCache->getLastModifiedFile();
        $cacheCreated = $ccCache->getCurrentCacheStamp();

        if($lastModified > $cacheCreated OR $cacheCreated == '') {
            if($cacheCreated == '') {
                $cacheCreated = $lastModified;
            }
            $ccCache->createCache($lastModified, $cacheCreated);
        }
        // return success, then JS redirect
        $this->renderText('{success:true}');
        return sfView::NONE;
    }
예제 #19
0
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once dirname(__FILE__) . '/../../../bootstrap/task.php';
$t = new lime_test(2);
$dispatcher = new sfEventDispatcher();
$formatter = new sfFormatter();
$task = new sfGenerateProjectTask($dispatcher, $formatter);
$task->run(array('test'));
$task = new sfGenerateAppTask($dispatcher, $formatter);
$task->run(array('frontend'));
require_once sfConfig::get('sf_root_dir') . '/config/ProjectConfiguration.class.php';
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'test', true);
// Put something in the cache
$file = sfConfig::get('sf_config_cache_dir') . DIRECTORY_SEPARATOR . 'test';
touch($file);
$t->ok(file_exists($file), 'The test file is in the cache');
$task = new sfCacheClearTask($dispatcher, $formatter);
$task->run();
$t->ok(!file_exists($file), 'The test file is removed by the cache:clear task');
예제 #20
0
 protected function _clearCache()
 {
     chdir(sfConfig::get('sf_root_dir'));
     $task = new sfCacheClearTask($this->_dispatcher, $this->_formatter);
     $this->logTaskCall('cache', 'Clearing cache', 'cache:clear');
     $this->_disableOutput();
     $task->run();
     $this->_enableOutput();
     $this->logSection('cache', '...finished clearing cache');
 }
 protected function installPlugins()
 {
     $task = new sfCacheClearTask($this->dispatcher, $this->formatter);
     $task->run();
     $task = new openpnePermissionTask($this->dispatcher, $this->formatter);
     $task->run();
     $task = new opPluginSyncTask($this->dispatcher, $this->formatter);
     $task->run();
 }
예제 #22
0
 protected function execute($arguments = array(), $options = array())
 {
     $root = sfConfig::get('sf_root_dir');
     $flavor = $root . '/flavors/' . $arguments['flavor'];
     if (!is_dir($flavor)) {
         $this->logSection('Error', 'The provided flavor does not exist the flavors/ directory', null, 'ERROR');
         return false;
     }
     $web = sfConfig::get('sf_web_dir');
     $web_css = $web . '/css';
     $web_img = $web . '/images';
     $pm_pdf_kit_cfg = sfConfig::get('sf_apps_dir') . '/backend/config/pm_pdf_kit.yml';
     $files = array();
     foreach (array($web_css, $web_img, $pm_pdf_kit_cfg) as $file) {
         if (file_exists($file)) {
             $files[] = $file;
         }
     }
     if (!empty($files)) {
         $this->logSection('Assets', 'Deleting the existing assets');
         $this->getFilesystem()->remove($files);
     } else {
         $this->logSection('Assets', 'No existing assets found');
     }
     $this->logSection('Assets', 'Linking the chosen flavor: ' . $arguments['flavor']);
     $flavor_css = $flavor . '/web/css';
     $flavor_img = $flavor . '/web/images';
     $pm_pdf_kit = $flavor . '/config/pm_pdf_kit.yml';
     $this->getFilesystem()->symlink($flavor_css, $web_css, true);
     $this->getFilesystem()->symlink($flavor_img, $web_img, true);
     $this->getFilesystem()->symlink($pm_pdf_kit, $pm_pdf_kit_cfg, true);
     $this->logSection('Config', 'Updating configuration');
     $cfg_dir = sfConfig::get('sf_config_dir');
     $configuration = array('nc_flavor' => array('flavors' => array('root_dir' => 'flavors', 'current' => $arguments['flavor'])));
     $updated = @file_put_contents($cfg_dir . '/nc_flavor.yml', sfYaml::dump($configuration));
     if ($updated === false) {
         $this->logSection('Config', 'Unable to update configuration', null, 'ERROR');
         $this->logSection('Config', "Please update your configuration file {$cfg_dir}/nc_flavor.yml with this contents:");
         $this->logBlock(sfYamlInline::dump($configuration), 'COMMENT');
     } else {
         $this->logSection('Flavor', 'Successfully updated flavor configuration file');
     }
     if ($updated === false) {
         $this->logSection('Config', 'Unable to update configuration', null, 'ERROR');
         $this->logBlock($school_behavior, 'COMMENT');
     } else {
         $this->logSection('Behavior', 'Successfully updated school_behavior configuration file');
     }
     $cc = new sfCacheClearTask($this->dispatcher, $this->formatter);
     $cc->run();
     $this->logSection('Done', ':)');
 }
    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;
        $lowerName = str_replace('-', '_', Doctrine_Inflector::urlize($name));
        if ($contentType) {
            $pluginYamlSchema = <<<EOF
---
{$contentType}:
  actAs: [sfSympalContentTypeTemplate]
  columns:
    title: string(255)
    body: clob
EOF;
            $pluginInstallDataFixtures = <<<EOF
# {$pluginName} install data fixtures
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/install.yml'] = $pluginInstallDataFixtures;
        }
        if (isset($pluginYamlSchema)) {
            $itemsToCreate['config/doctrine/schema.yml'] = $pluginYamlSchema;
        }
        if (isset($options['theme'])) {
            $itemsToCreate['config/app.yml'] = sprintf('all:
  sympal_config:
    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/css/default.css');
        }
        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);
        }
        $cc = new sfCacheClearTask($this->dispatcher, $this->formatter);
        $ret = $cc->run(array(), array());
    }