| 849 | | public static function generateMigrationClass($className, $directory) |
| 850 | | { |
| 851 | | $migration = new Doctrine_Migration($directory); |
| 852 | | $next = (string) $migration->getNextVersion(); |
| 853 | | |
| 854 | | $fileName = str_repeat('0', (3 - strlen($next))) . $next . '_' . self::tableize($className) . '.class.php'; |
| 855 | | $path = $directory . DIRECTORY_SEPARATOR . $fileName; |
| 856 | | |
| 857 | | $code = '<?php' . PHP_EOL; |
| 858 | | $code .= "// Automatically generated by the Doctrine ORM Framework\n"; |
| 859 | | $code .= "class " . self::classify($className) . " extends Doctrine_Migration\n"; |
| 860 | | $code .= "{\n"; |
| 861 | | $code .= "\tpublic function up()\n\t{ }\n\n"; |
| 862 | | $code .= "\tpublic function down()\n\t{ }\n"; |
| 863 | | $code .= "}"; |
| 864 | | |
| 865 | | file_put_contents($path, $code); |
| | 849 | public static function generateMigrationClass($className, $migrationsPath) |
| | 850 | { |
| | 851 | $builder = new Doctrine_Migration_Builder($migrationsPath); |
| | 852 | |
| | 853 | return $builder->generateMigrationClass($className); |
| | 854 | } |
| | 855 | |
| | 856 | /** |
| | 857 | * generateMigrationsFromDb |
| | 858 | * |
| | 859 | * @param string $migrationsPath |
| | 860 | * @return void |
| | 861 | */ |
| | 862 | public function generateMigrationsFromDb($migrationsPath) |
| | 863 | { |
| | 864 | $builder = new Doctrine_Migration_Builder($migrationsPath); |
| | 865 | |
| | 866 | return $builder->generateMigrationsFromDb(); |
| | 867 | } |
| | 868 | |
| | 869 | /** |
| | 870 | * generateMigrationsFromModels |
| | 871 | * |
| | 872 | * @param string $migrationsPath |
| | 873 | * @param string $modelsPath |
| | 874 | * @return void |
| | 875 | */ |
| | 876 | public function generateMigrationsFromModels($migrationsPath, $modelsPath = null) |
| | 877 | { |
| | 878 | $builder = new Doctrine_Migration_Builder($migrationsPath); |
| | 879 | |
| | 880 | return $builder->generateMigrationsFromModels($modelsPath); |
| | 881 | } |
| | 882 | |
| | 883 | /** |
| | 884 | * getTable |
| | 885 | * |
| | 886 | * @param string $tableName |
| | 887 | * @return void |
| | 888 | */ |
| | 889 | public function getTable($tableName) |
| | 890 | { |
| | 891 | return Doctrine_Manager::table($tableName); |
| | 892 | } |
| | 893 | |
| | 894 | /** |
| | 895 | * connection |
| | 896 | * |
| | 897 | * @param string $adapter |
| | 898 | * @param string $name |
| | 899 | * @return void |
| | 900 | */ |
| | 901 | public function connection($adapter, $name = null) |
| | 902 | { |
| | 903 | return Doctrine_Manager::connection($adapter, $name); |