1 |
<?php
|
2 |
require_once('spyc.php');
|
3 |
|
4 |
/*
|
5 |
* $Id: Yml.php 1080 2007-02-10 18:17:08Z jwage $
|
6 |
*
|
7 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
8 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
9 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
10 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
11 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
12 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
13 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
14 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
15 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
16 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
17 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
18 |
*
|
19 |
* This software consists of voluntary contributions made by many individuals
|
20 |
* and is licensed under the LGPL. For more information, see
|
21 |
* <http://www.phpdoctrine.com>.
|
22 |
*/
|
23 |
|
24 |
/**
|
25 |
* Doctrine_Parser_Yml
|
26 |
*
|
27 |
* @package Doctrine
|
28 |
* @subpackage Parser
|
29 |
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
30 |
* @link www.phpdoctrine.com
|
31 |
* @since 1.0
|
32 |
* @version $Revision: 1080 $
|
33 |
* @author Jonathan H. Wage <jwage@mac.com>
|
34 |
*/
|
35 |
class Doctrine_Parser_Yml extends Doctrine_Parser
|
36 |
{
|
37 |
/**
|
38 |
* dumpData
|
39 |
*
|
40 |
* Dump an array of data to a specified path or return
|
41 |
*
|
42 |
* @param string $array Array of data to dump to yaml
|
43 |
* @param string $path Path to dump the yaml to
|
44 |
* @return string $yaml
|
45 |
* @return void
|
46 |
*/
|
47 |
public function dumpData($array, $path = null)
|
48 |
{
|
49 |
$spyc = new Doctrine_Spyc();
|
50 |
|
51 |
$data = $spyc->dump($array, false, false);
|
52 |
|
53 |
return $this->doDump($data, $path);
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
* loadData
|
58 |
*
|
59 |
* Load and parse data from a yml file
|
60 |
*
|
61 |
* @param string $path Path to load yaml data from
|
62 |
* @return array $array Array of parsed yaml data
|
63 |
*/
|
64 |
public function loadData($path)
|
65 |
{
|
66 |
$contents = $this->doLoad($path);
|
67 |
|
68 |
$spyc = new Doctrine_Spyc();
|
69 |
|
70 |
$array = $spyc->load($contents);
|
71 |
|
72 |
return $array;
|
73 |
}
|
74 |
} |