diff -r bbdc7f9aa25e -r 03b14b0fe101 vendor/doctrine-migrations/lib/Doctrine/DBAL/Migrations/Configuration/AbstractFileConfiguration.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/doctrine-migrations/lib/Doctrine/DBAL/Migrations/Configuration/AbstractFileConfiguration.php Fri Nov 25 18:55:43 2011 +0100 @@ -0,0 +1,93 @@ +. +*/ + +namespace Doctrine\DBAL\Migrations\Configuration; + +use Doctrine\DBAL\Migrations\MigrationsException; + +/** + * Abstract Migration Configuration class for loading configuration information + * from a configuration file (xml or yml). + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @author Jonathan H. Wage + */ +abstract class AbstractFileConfiguration extends Configuration +{ + /** + * The configuration file used to load configuration information + * + * @var string + */ + private $file; + + /** + * Whether or not the configuration file has been loaded yet or not + * + * @var bool + */ + private $loaded = false; + + /** + * Load the information from the passed configuration file + * + * @param string $file The path to the configuration file + * @return void + * @throws MigrationException $exception Throws exception if configuration file was already loaded + */ + public function load($file) + { + if ($this->loaded) { + throw MigrationsException::configurationFileAlreadyLoaded(); + } + if (file_exists($path = getcwd() . '/' . $file)) { + $file = $path; + } + $this->file = $file; + $this->doLoad($file); + $this->loaded = true; + } + + protected function getDirectoryRelativeToFile($file, $input) + { + $path = realpath(dirname($file) . '/' . $input); + if ($path !== false) { + $directory = $path; + } else { + $directory = $input; + } + return $directory; + } + + public function getFile() + { + return $this->file; + } + + /** + * Abstract method that each file configuration driver must implement to + * load the given configuration file whether it be xml, yaml, etc. or something + * else. + * + * @param string $file The path to a configuration file. + */ + abstract protected function doLoad($file); +} \ No newline at end of file