Created
January 11, 2010 19:21
-
-
Save ollym/274500 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get a recursive array of every model | |
$models = new RecursiveArrayIterator(Kohana::list_files('classes/model')); | |
// Loop through each model recursively | |
foreach (new RecursiveIteratorIterator($models) as $model => $path) | |
{ | |
// Clean up the model name, and make it relative to the model folder | |
$model = trim(str_replace(array('classes/model', EXT), '', $model), DIRECTORY_SEPARATOR); | |
// Replace the directory seperators with underscores | |
$class = str_replace(DIRECTORY_SEPARATOR, '_', $model); | |
// Create a new reflection class of the model | |
$class = new ReflectionClass('model_'.$class); | |
// Check if the class is instantiable | |
if ($class->isInstantiable()) | |
{ | |
// If it is we can migrate it | |
Migration::factory($model, 'sprig') | |
->sync(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment