1
0
mirror of synced 2025-01-07 09:37:11 +03:00
doctrine2/website/plugins/sfDoctrinePlugin/lib/sfDoctrineSchemasConfigHandler.class.php
2007-08-31 23:41:48 +00:00

54 lines
1.5 KiB
PHP

<?php
/*
* This file is part of the sfDoctrine package.
* (c) 2006-2007 Olivier Verdier <Olivier.Verdier@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* sfDoctrineSchemasConfigHandler parses the config/schemas.yml config file
*
* @package symfony.plugins
* @subpackage sfDoctrine
* @author Stephen Leavitt <stephen.leavitt@gmail.com>
* @version SVN: $Id$
*/
class sfDoctrineSchemasConfigHandler extends sfYamlConfigHandler
{
public function execute( $configFiles )
{
$this->initialize();
$mappings = $this->parseYamls( $configFiles );
$data = array();
$data[] = '$manager = Doctrine_Manager::getInstance();'."\n";
foreach ( $mappings as $mapping => $schemas )
{
foreach ( $schemas as $schema )
{
$path = sfConfig::get( 'sf_config_dir' ) . '/doctrine/' . $schema . '.yml';
$components = array_keys( sfYaml::load( $path ) );
foreach ( $components as $component )
{
$data[] = "\$manager->bindComponent('{$component}', '{$mapping}');";
}
}
}
// compile data
$retval = sprintf("<?php\n".
"// auto-generated by sfDoctrineSchemasConfigHandler\n".
"// date: %s\n%s\n",
date('Y-m-d H:i:s'), implode("\n", $data));
return $retval;
}
}