Ejemplo n.º 1
0
 public static function getConfigFile($name)
 {
     if (file_exists(BASE_PATH . '/_data/' . $name . '.yaml')) {
         return Dipper::parse(file_get_contents(BASE_PATH . '/_data/' . $name . '.yaml'));
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * Load the YAML string into an DOMDocument
  *
  * @param mixed $source
  * @param string $contentType
  * @param array $options
  * @return Document|NULL
  */
 public function load($source, $contentType, array $options = [])
 {
     if ($this->supports($contentType)) {
         if (FALSE === strpos($source, "\n")) {
             $source = file_get_contents($source);
         }
         $yaml = Dipper::parse($source);
         if (!empty($yaml) || is_array($yaml)) {
             $dom = new Document('1.0', 'UTF-8');
             $dom->appendChild($root = $dom->createElementNS(self::XMLNS, 'json:json'));
             $this->transferTo($root, $yaml);
             return $dom;
         }
     }
     return NULL;
 }
Ejemplo n.º 3
0
function yaml_decode($yaml)
{
    if ($yaml[0] == '{') {
        return json_decode($yaml, true);
    }
    return Dipper::parse($yaml);
}
Ejemplo n.º 4
0
 public function asString()
 {
     $jsondom = new \FluentDOM\Serializer\Json($this->_document);
     $yaml = Dipper::make($jsondom->jsonSerialize());
     return (string) $yaml;
 }