public function setup()
 {
     require_once dirname(__FILE__) . '/../lib/vendor/php-github-api/lib/phpGithubApi.php';
     $this->dispatcher->connect('component.method_not_found', array('sfActionExtra', 'observeMethodNotFound'));
     sfYaml::setSpecVersion('1.1');
     $this->enablePlugins(array('sfDoctrinePlugin', 'csAdminGeneratorPlugin', 'csDoctrineActAsAttachablePlugin', 'csDoctrineActAsSortablePlugin', 'csDoctrineMarkdownPlugin', 'csFormTransformPlugin', 'csNavigationPlugin', 'csSEOToolkitPlugin', 'csThumbnailPlugin', 'sfCommentsPlugin', 'sfDoctrineGuardPlugin', 'sfDoctrineSettingsPlugin', 'sfFormExtraPlugin', 'sfGoogleAnalyticsPlugin', 'sfGravatarPlugin', 'sfJqueryReloadedPlugin', 'sfLucenePlugin', 'sfTaskExtraPlugin'));
 }
 public function setup()
 {
     $this->dispatcher->connect('component.method_not_found', array('sfActionExtra', 'observeMethodNotFound'));
     sfYaml::setSpecVersion('1.1');
     // for compatibility / remove and enable only the plugins you want
     $this->enablePlugins(array('sfDoctrinePlugin', 'sfDoctrineGuardPlugin', 'sfFormExtraPlugin', 'sfGoogleAnalyticsPlugin', 'sfTaskExtraPlugin', 'csDoctrineActAsSortablePlugin', 'sfThemeGeneratorPlugin', 'sfHadoriThemePlugin'));
 }
Ejemplo n.º 3
0
 public static function emitFile($data, $file)
 {
     if (file_exists($file) and !is_writable($file)) {
         throw new pakeException('Not enough rights to overwrite "' . $file . '"');
     }
     $dir = dirname($file);
     pake_mkdirs($dir);
     if (!is_writable($dir)) {
         throw new pakeException('Not enough rights to create file in "' . $dir . '"');
     }
     if (extension_loaded('yaml')) {
         // not yet implemented:
         // yaml_emit_file($file, $data);
         // so using this instead:
         if (false === file_put_contents($file, yaml_emit($data))) {
             throw new pakeException("Couldn't create file");
         }
     } else {
         sfYaml::setSpecVersion('1.1');
         // more compatible
         $dumper = new sfYamlDumper();
         if (false === file_put_contents($file, $dumper->dump($data, 1))) {
             throw new pakeException("Couldn't create file");
         }
     }
     pake_echo_action('file+', $file);
 }
 public function setup()
 {
     sfYaml::setSpecVersion('1.1');
     $this->enableAllPluginsExcept(array('sfPropelPlugin'));
     $this->enablePlugins('sfFormExtraPlugin');
     $this->enablePlugins('sfDoctrineJCroppablePlugin');
     $this->enablePlugins('sfThumbnailPlugin');
 }
 public function setup()
 {
     sfYaml::setSpecVersion('1.1');
     require_once sfConfig::get('sf_plugins_dir') . '/sfSympalPlugin/config/sfSympalPluginConfiguration.class.php';
     sfSympalPluginConfiguration::enableSympalPlugins($this);
     $configPath = dirname(__FILE__) . '/server_config.php';
     if (file_exists($configPath)) {
         require $configPath;
     }
 }
 public function upgrade()
 {
     $specVersion = sfYaml::getSpecVersion();
     $queue = array();
     $success = true;
     $finder = sfFinder::type('file')->name('*.yml')->prune('vendor');
     foreach ($finder->in(sfConfig::get('sf_root_dir')) as $file) {
         // attempt to upgrade booleans
         $original = file_get_contents($file);
         $upgraded = sfToolkit::pregtr($original, array('/^([^:]+: +)(?:on|y(?:es)?|\\+)(\\s*(#.*)?)$/im' => '\\1true\\2', '/^([^:]+: +)(?:off|no?|-)(\\s*(#.*)?)$/im' => '\\1false\\2'));
         try {
             sfYaml::setSpecVersion('1.1');
             $yaml11 = sfYaml::load($original);
             sfYaml::setSpecVersion('1.2');
             $yaml12 = sfYaml::load($upgraded);
         } catch (Exception $e) {
             // unable to load the YAML
             $yaml11 = 'foo';
             $yaml12 = 'bar';
         }
         if ($yaml11 == $yaml12) {
             if ($original != $upgraded) {
                 $this->getFilesystem()->touch($file);
                 file_put_contents($file, $upgraded);
             }
         } else {
             $this->logSection('yaml', 'Unable to upgrade ' . sfDebug::shortenFilePath($file), null, 'ERROR');
             // force project to use YAML 1.1 spec
             if ('1.1' != $specVersion) {
                 $specVersion = '1.1';
                 $class = sfClassManipulator::fromFile(sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php');
                 $original = $class->getCode();
                 $modified = $class->wrapMethod('setup', 'sfYaml::setSpecVersion(\'1.1\');');
                 if ($original != $modified && $this->askConfirmation(array('Unable to convert YAML file:', sfDebug::shortenFilePath($file), '', 'Would you like to force YAML to be parsed with the 1.1 specification? (Y/n)'), 'QUESTION_LARGE')) {
                     $this->logSection('yaml', 'Forcing YAML 1.1 spec');
                     $this->getFilesystem()->touch($class->getFile());
                     $class->save();
                 } else {
                     $this->logBlock(array('Unable to either upgrade YAML files or force 1.1 spec.', '(see UPGRADE_TO_1_3 file for more information)'), 'ERROR_LARGE');
                 }
             }
             $success = false;
         }
     }
     if ($success && '1.1' == $specVersion) {
         $file = sfConfig::get('sf_config_dir') . '/ProjectConfiguration.class.php';
         $original = file_get_contents($file);
         $modified = preg_replace('/^\\s*sfYaml::setSpecVersion\\(\'1\\.1\'\\);\\n/im', '', $original);
         if ($original != $modified) {
             $this->logSection('yaml', 'Removing setting of YAML 1.1 spec');
             $this->getFilesystem()->touch($file);
             file_put_contents($file, $modified);
         }
     }
 }
 public function __construct($data)
 {
     try {
         $version = sfYaml::getSpecVersion();
         sfYaml::setSpecVersion('1.2');
         $this->data = $this->parse($data);
         sfYaml::setSpecVersion($version);
     } catch (InvalidArgumentException $e) {
         $this->errors[] = $e->getMessage();
     }
 }
 public function getYaml($entities, $locale)
 {
     // Use the Zend copy of this script to prevent class conflicts when RailsYaml is included
     require_once 'thirdparty/zend_translate_railsyaml/library/Translate/Adapter/thirdparty/sfYaml/lib' . '/sfYamlDumper.php';
     // Unflatten array
     $entitiesNested = array();
     foreach ($entities as $entity => $spec) {
         // Legacy support: Don't count *.ss as namespace
         $entity = preg_replace('/\\.ss\\./', '___ss.', $entity);
         $parts = explode('.', $entity);
         $currLevel =& $entitiesNested;
         while ($part = array_shift($parts)) {
             $part = str_replace('___ss', '.ss', $part);
             if (!isset($currLevel[$part])) {
                 $currLevel[$part] = array();
             }
             $currLevel =& $currLevel[$part];
         }
         $currLevel = $spec[0];
     }
     // Write YAML
     $oldVersion = sfYaml::getSpecVersion();
     sfYaml::setSpecVersion('1.1');
     $yamlHandler = new sfYaml();
     // TODO Dumper can't handle YAML comments, so the context information is currently discarded
     $result = $yamlHandler->dump(array($locale => $entitiesNested), 99);
     sfYaml::setSpecVersion($oldVersion);
     return $result;
 }
Ejemplo n.º 9
0
<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once __DIR__ . '/../../bootstrap/unit.php';
sfYaml::setSpecVersion('1.1');
$t = new lime_test(150);
$parser = new sfYamlParser();
$path = __DIR__ . '/fixtures';
$files = $parser->parse(file_get_contents($path . '/index.yml'));
foreach ($files as $file) {
    $t->diag($file);
    $yamls = file_get_contents($path . '/' . $file . '.yml');
    // split YAMLs documents
    foreach (preg_split('/^---( %YAML\\:1\\.0)?/m', $yamls) as $yaml) {
        if (!$yaml) {
            continue;
        }
        $test = $parser->parse($yaml);
        if (isset($test['todo']) && $test['todo']) {
            $t->todo($test['test']);
        } else {
            $expected = var_export(eval('return ' . trim($test['php']) . ';'), true);
            $t->is(var_export($parser->parse($test['yaml']), true), $expected, $test['test']);
        }
    }
 public function setup()
 {
     sfYaml::setSpecVersion('1.1');
     // for compatibility / remove and enable only the plugins you want
     $this->enableAllPluginsExcept('sfPropelPlugin');
 }
 public function setup()
 {
     sfYaml::setSpecVersion('1.1');
     // for compatibility / remove and enable only the plugins you want
     $this->enablePlugins(array('sfDoctrinePlugin', 'sfDoctrineGuardPlugin', 'csDoctrineActAsSortablePlugin', 'sfFormExtraPlugin', 'sfGoogleAnalyticsPlugin', 'sfLucenePlugin', 'sfTaskExtraPlugin', 'sfPhpExcelPlugin', 'csBackupPlugin'));
 }