本文整理汇总了PHP中sfYaml::Load方法的典型用法代码示例。如果您正苦于以下问题:PHP sfYaml::Load方法的具体用法?PHP sfYaml::Load怎么用?PHP sfYaml::Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfYaml
的用法示例。
在下文中一共展示了sfYaml::Load方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run_opp_update_ddl_from_yaml
/**
* Processa il file specificato in --yaml-file per l'upgrade di un atto
*
*/
function run_opp_update_ddl_from_yaml($task, $args, $options)
{
static $loaded;
// load application context
if (!$loaded) {
_loader();
}
$dry_run = false;
if (array_key_exists('dry-run', $options)) {
$dry_run = true;
}
if (array_key_exists('yaml-file', $options)) {
$yaml_file = strtolower($options['yaml-file']);
} else {
throw new Exception("Specificare il file contenente i dati dei ddl con l'opzione --yaml-file=FILE_COMPLETE_PATH");
}
echo "memory usage: " . memory_get_usage() . "\n";
$start_time = time();
$msg = sprintf("upgrade ddl da {$yaml_file}\n");
echo pakeColor::colorize($msg, array('fg' => 'cyan', 'bold' => true));
if (file_exists($yaml_file)) {
$up_ddl = sfYaml::Load($yaml_file);
} else {
throw new Exception("Impossibile trovare il file {$yaml_file}");
}
$con = Propel::getConnection(OppAttoPeer::DATABASE_NAME);
$opp_id = $up_ddl['opp_id'];
$atto = OppAttoPeer::retrieveByPK($opp_id);
$parl_id = $up_ddl['parl_id'];
if (is_null($atto->getParlamentoId()) || $atto->getParlamentoId() != $parl_id) {
$atto->setParlamentoId($parl_id);
}
$key = 'titolo';
if (array_key_exists($key, $up_ddl)) {
$titolo = $up_ddl['titolo'];
$atto->setTitolo($titolo);
print "{$key}\n";
print str_repeat("=", strlen($key)) . "\n";
print "{$titolo}\n";
print "\n";
}
# firme
$firmatari = array('P' => 'primi_firmatari', 'R' => 'relatori', 'C' => 'co_firmatari');
foreach ($firmatari as $tipo_firma => $key) {
if (array_key_exists($key, $up_ddl) && !is_null($up_ddl[$key])) {
print "{$key}\n";
print str_repeat("=", strlen($key)) . "\n";
foreach ($up_ddl[$key] as $id => $signature_data) {
$ca = new OppCaricaHasAtto();
$ca->setAttoId($opp_id);
$ca->setCaricaId($id);
$ca->setTipo($tipo_firma);
$name = $signature_data['nome'];
$signature_date = $signature_data['data_firma'];
$ca->setData($signature_date);
$ca->save();
print " {$name} ({$id}) il {$signature_date}\n";
}
print "\n";
}
}
# commissioni
$commissioni = array('referente', 'consultiva');
foreach ($commissioni as $tipo_commissione) {
if (array_key_exists($tipo_commissione, $up_ddl)) {
print "{$tipo_commissione}\n";
print str_repeat("=", strlen($tipo_commissione)) . "\n";
foreach ($up_ddl[$tipo_commissione] as $id => $name) {
$as = new OppAttoHasSede();
$as->setAttoId($opp_id);
$as->setSedeId($id);
$as->setTipo(ucfirst($tipo_commissione));
$as->save();
print " {$name} ({$id})\n";
}
print "\n";
}
}
# tagging
if (array_key_exists('tags', $up_ddl)) {
print "tagging\n";
print "=======\n";
foreach ($up_ddl['tags'] as $tag_id => $name) {
$t = new Tagging();
$t->setTaggableModel('OppAtto');
$t->setTaggableId($opp_id);
$t->setTagId($tag_id);
$t->save();
print " {$name} ({$tag_id})\n";
}
print "\n";
}
# documenti
if (array_key_exists('documenti', $up_ddl)) {
print "documenti\n";
print "=========\n";
//.........这里部分代码省略.........