Doctrine 1.2.4
Doctrine_Parser_Yml Class Reference

Inherits Doctrine_Parser.

Public Member Functions

 doDump ($data, $path=null)
 
 doLoad ($path)
 
 dumpData ($array, $path=null, $charset=null)
 
 loadData ($path)
 

Static Public Member Functions

static dump ($array, $type= 'xml', $path=null, $charset=null)
 
static getParser ($type)
 
static load ($path, $type= 'xml')
 

Detailed Description

Definition at line 33 of file Yml.php.

Member Function Documentation

Doctrine_Parser::doDump (   $data,
  $path = null 
)
inherited

doDump

Parameters
string$data
string$path
Returns
void

Definition at line 145 of file Parser.php.

{
if ($path !== null) {
return file_put_contents($path, $data);
} else {
return $data;
}
}
Doctrine_Parser::doLoad (   $path)
inherited

doLoad

Get contents whether it is the path to a file file or a string of txt. Either should allow php code in it.

Parameters
string$path
Returns
void

Definition at line 120 of file Parser.php.

{
ob_start();
if ( ! file_exists($path)) {
$contents = $path;
$path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'dparser_' . microtime();
file_put_contents($path, $contents);
}
include($path);
// Fix #1569. Need to check if it's still all valid
$contents = ob_get_clean(); //iconv("UTF-8", "UTF-8", ob_get_clean());
return $contents;
}
static Doctrine_Parser::dump (   $array,
  $type = 'xml',
  $path = null,
  $charset = null 
)
staticinherited

dump

Interface for pulling and dumping data to a file

Parameters
string$array
string$path
string$type
string$charsetThe charset of the data being dumped
Returns
void
Author
Jonathan H. Wage

Definition at line 104 of file Parser.php.

{
$parser = self::getParser($type);
return $parser->dumpData($array, $path, $charset);
}
Doctrine_Parser_Yml::dumpData (   $array,
  $path = null,
  $charset = null 
)

dumpData

Dump an array of data to a specified path or return

Exceptions
Doctrine_Parser_Exceptiondumping error
Parameters
string$arrayArray of data to dump to yaml
string$pathPath to dump the yaml to
Returns
string $yaml
void

Definition at line 46 of file Yml.php.

{
try {
$data = sfYaml::dump($array, 6);
return $this->doDump($data, $path);
} catch(InvalidArgumentException $e) {
// rethrow the exceptions
$rethrowed_exception = new Doctrine_Parser_Exception($e->getMessage(), $e->getCode());
throw $rethrowed_exception;
}
}
static Doctrine_Parser::getParser (   $type)
staticinherited

getParser

Get instance of the specified parser

Parameters
string$type
Returns
void
Author
Jonathan H. Wage

Definition at line 68 of file Parser.php.

{
$class = 'Doctrine_Parser_'.ucfirst($type);
return new $class;
}
static Doctrine_Parser::load (   $path,
  $type = 'xml' 
)
staticinherited

load

Interface for loading and parsing data from a file

Parameters
string$path
string$type
Returns
void
Author
Jonathan H. Wage

Definition at line 85 of file Parser.php.

{
$parser = self::getParser($type);
return (array) $parser->loadData($path);
}
Doctrine_Parser_Yml::loadData (   $path)

loadData

Load and parse data from a yml file

Exceptions
Doctrine_Parser_Exceptionparsing error
Parameters
string$pathPath to load yaml data from
Returns
array $array Array of parsed yaml data

Definition at line 71 of file Yml.php.

{
try {
/*
* I still use the doLoad method even if sfYaml can load yml from a file
* since this way Doctrine can handle file on it own.
*/
$contents = $this->doLoad($path);
$array = sfYaml::load($contents);
return $array;
} catch(InvalidArgumentException $e) {
// rethrow the exceptions
$rethrowed_exception = new Doctrine_Parser_Exception($e->getMessage(), $e->getCode());
throw $rethrowed_exception;
}
}

The documentation for this class was generated from the following file: