<?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; } }