コード例 #1
0
 /**
  * Sets the $_params array as sfConfig variables
  */
 protected function _prepareParams()
 {
     foreach ($this->_params as $key => $value) {
         if ($value) {
             sfSympalConfig::set('sympal_install_admin_' . $key, $value);
         }
     }
 }
コード例 #2
0
 protected function execute($arguments = array(), $options = array())
 {
     if (!$options['no-confirmation'] && !$this->askConfirmation(array(sprintf('You are about to create a new site named "%s"', $arguments['site']), 'Are you sure you want to proceed? (y/N)'), 'QUESTION_LARGE', false)) {
         $this->logSection('sympal', 'Install task aborted');
         return 1;
     }
     if (isset($options['interactive']) && $options['interactive']) {
         sfSympalConfig::set('sympal_install_admin_email_address', $this->askAndValidate('Enter E-Mail Address:', new sfValidatorString()));
         sfSympalConfig::set('sympal_install_admin_first_name', $this->askAndValidate('Enter First Name:', new sfValidatorString()));
         sfSympalConfig::set('sympal_install_admin_last_name', $this->askAndValidate('Enter Last Name:', new sfValidatorString()));
         sfSympalConfig::set('sympal_install_admin_username', $this->askAndValidate('Enter Username:'******'sympal_install_admin_password', $this->askAndValidate('Enter Password:'******'site']);
     $this->_prepareApplication($arguments['site']);
     $databaseManager = new sfDatabaseManager($this->configuration);
     $site = $this->_getOrCreateSite($arguments, $options);
 }
コード例 #3
0
 /**
  * Write a setting to the config/app.yml. The api of this is the same as set()
  *
  * @see sfSympalConfig::set()
  * @param string $group 
  * @param string $name 
  * @param string $value 
  * @param string $application Whether or not to write this setting to the app config file
  * @return void
  */
 public static function writeSetting($group, $name, $value = null, $application = false)
 {
     if ($application) {
         $path = sfConfig::get('sf_app_dir') . '/config/app.yml';
     } else {
         $path = sfConfig::get('sf_config_dir') . '/app.yml';
     }
     if (!file_exists($path)) {
         touch($path);
     }
     $array = (array) sfYaml::load(file_get_contents($path));
     if ($value === null) {
         $array['all']['sympal_config'][$group] = $name;
     } else {
         $array['all']['sympal_config'][$group][$name] = $value;
     }
     sfSympalConfig::set($group, $name, $value);
     file_put_contents($path, sfYaml::dump($array, 4));
 }
コード例 #4
0
ファイル: sfSympalConfigTest.php プロジェクト: sympal/sympal
<?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');
コード例 #5
0
try {
    $transformer->getTransformerCallbacksTest();
    $t->fail('Exception not thrown');
} catch (sfException $e) {
    $t->pass('Exception thrown');
}
/*
 * Test the transformation process
 */
$t->info('2 - Test the transformation process');
$t->info('  2.1 - Setup a unit_test transformer');
$markdownConfig['transformers'] = array('unit_test');
sfSympalConfig::set('content_slot_types', 'Markdown', $markdownConfig);
$t->info('  2.2 - First transformer should always return static text "testing"');
sfSympalConfig::set('slot_transformers', 'unit_test', array('myUnitTestTransformer', 'transform1'));
test_transformer_return($t, $transformer, 'testing', array(), 'testing');
$t->info('  2.3 - Transformer will change "Markdown" to "Markup"');
sfSympalConfig::set('slot_transformers', 'unit_test', array('myUnitTestTransformer', 'transform2'));
test_transformer_return($t, $transformer, '__Some Markup Content__', array(), '__Some Markup Content__');
$t->info('  2.4 - Transformer will include a callback wildcard');
sfSympalConfig::set('slot_transformers', 'unit_test', array('myUnitTestTransformer', 'transform3'));
$tokenCallbacks = array('%language%' => array('callback' => array('myUnitTestTransformer', 'languageCallback'), 'args' => array('HT', 'ML')));
test_transformer_return($t, $transformer, '__Some %language% Content__', $tokenCallbacks, '__Some HTML Content__');
// tests the return values of a run in the transformer
function test_transformer_return(lime_test $t, sfSympalContentSlotTransformerTest $transformer, $transformedContent, $tokenCallbacks, $result)
{
    $transformerResult = $transformer->render();
    $t->is($transformer->getProp('_transformedContent'), $transformedContent, sprintf('->_transformedContent set to "%s"', $transformedContent));
    $t->is($transformer->getProp('_tokenCallbacks'), $tokenCallbacks, '->_tokenCallbacks matches');
    $t->is($transformerResult, $result, sprintf('The end result is "%s"', $result));
}