Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Config / Writer / Yaml.php
blobbe2aa07a0486493505409e809ed7c100f441de54
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Config\Writer;
12 use Zend\Config\Exception;
14 class Yaml extends AbstractWriter
16 /**
17 * YAML encoder callback
19 * @var callable
21 protected $yamlEncoder;
23 /**
24 * Constructor
26 * @param callable|string|null $yamlEncoder
28 public function __construct($yamlEncoder = null)
30 if ($yamlEncoder !== null) {
31 $this->setYamlEncoder($yamlEncoder);
32 } else {
33 if (function_exists('yaml_emit')) {
34 $this->setYamlEncoder('yaml_emit');
39 /**
40 * Get callback for decoding YAML
42 * @return callable
44 public function getYamlEncoder()
46 return $this->yamlEncoder;
49 /**
50 * Set callback for decoding YAML
52 * @param callable $yamlEncoder the decoder to set
53 * @return Yaml
54 * @throws Exception\InvalidArgumentException
56 public function setYamlEncoder($yamlEncoder)
58 if (!is_callable($yamlEncoder)) {
59 throw new Exception\InvalidArgumentException('Invalid parameter to setYamlEncoder() - must be callable');
61 $this->yamlEncoder = $yamlEncoder;
62 return $this;
65 /**
66 * processConfig(): defined by AbstractWriter.
68 * @param array $config
69 * @return string
70 * @throws Exception\RuntimeException
72 public function processConfig(array $config)
74 if (null === $this->getYamlEncoder()) {
75 throw new Exception\RuntimeException("You didn't specify a Yaml callback encoder");
78 $config = call_user_func($this->getYamlEncoder(), $config);
79 if (null === $config) {
80 throw new Exception\RuntimeException("Error generating YAML data");
83 return $config;