コード例 #1
0
ファイル: Markdown.php プロジェクト: jamesmoss/flywheel
 public function encode(array $data)
 {
     $body = isset($data[$this->contentFieldName]) ? $data[$this->contentFieldName] : '';
     unset($data[$this->contentFieldName]);
     $str = "---\n";
     $str .= parent::encode($data);
     $str .= "---\n";
     $str .= $body;
     return $str;
 }
コード例 #2
0
ファイル: schema.php プロジェクト: phaedryx/wannabe-mvc
function generate_schema($model)
{
    global $mysql;
    $cols = array();
    $result = mysql_query("DESCRIBE `{$model}`") or die("Error in query: {$sql} \n" . mysql_error() . "\n");
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $cols[$row['Field']] = $row;
    }
    $yaml = YAML::encode($cols);
    $comments = "# This file is auto-generated by script/generate_schema \n# Do not edit or you'll ruin Christmas!!\n\n";
    file_put_contents("db/schemas/{$model}.yml", $comments . $yaml);
}
コード例 #3
0
ファイル: loader.class.php プロジェクト: jonlb/jxLoader
 public function __construct($config)
 {
     $this->config = $config;
     $dir = dirname(__FILE__);
     if (file_exists($dir . '/repos.yml')) {
         $this->repos = YAML::decode_file($dir . '/repos.yml');
         if ($this->verify_repos() && file_exists($dir . '/flat.yml')) {
             $this->flat = YAML::decode_file($dir . '/flat.yml');
         } else {
             $this->flat = $this->flatten($this->repos);
         }
     } else {
         $this->rebuild();
     }
     //write file back out
     file_put_contents($dir . '/repos.yml', YAML::encode($this->repos));
     file_put_contents($dir . '/flat.yml', YAML::encode($this->flat));
 }
コード例 #4
0
ファイル: YAMLTest.php プロジェクト: gekt/www
 public function testEncoding()
 {
     $formatter = new YAML();
     $data = array('name' => 'Joe', 'age' => 21, 'employed' => true);
     $this->assertSame(file_get_contents(__DIR__ . '/fixtures/joe.yaml'), $formatter->encode($data));
 }