Created
August 28, 2010 19:21
-
-
Save harikt/555473 to your computer and use it in GitHub Desktop.
To create models specifically for the doctrine for each specific module for the videos of zendcasts.com . Keep this file in <project dir>/application/scriptsdoctrine.php Eg: $./doctrine < arguments for doctrine > module <module name > If no module is
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
<?php | |
// Define path to application directory | |
defined('APPLICATION_PATH') | |
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/..')); | |
// Define application environment | |
defined('APPLICATION_ENV') | |
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'doctrineCLI')); | |
// Ensure library/ is on include_path | |
set_include_path(implode(PATH_SEPARATOR, array( | |
realpath(APPLICATION_PATH . '/../library'), | |
get_include_path() | |
))); | |
/** Zend_Application */ | |
require_once 'Zend/Application.php'; | |
// Create application, bootstrap, and run | |
$application = new Zend_Application( | |
APPLICATION_ENV, | |
APPLICATION_PATH . '/configs/application.ini' | |
); | |
$application->getBootstrap()->bootstrap('doctrine'); | |
$config = $application->getOption('doctrine'); | |
$config = $application->getOption('doctrine'); | |
$length = strlen( APPLICATION_PATH ); | |
if(is_array($_SERVER['argv']) ) { | |
$modulePosition = array_keys( $_SERVER['argv'] , 'module'); | |
if ( !empty( $modulePosition ) ) { | |
$moduleName = $_SERVER['argv'][$modulePosition[0]+1]; | |
if ( is_dir( APPLICATION_PATH . "/modules/$moduleName" ) ) { | |
foreach( $config as $key => $value ) { | |
switch( $key ) { | |
case 'data_fixtures_path': | |
case 'sql_path' : | |
case 'migrations_path' : | |
case 'yaml_schema_path' : | |
case 'models_path' : | |
$config[$key] = APPLICATION_PATH . "/modules/$moduleName" . substr_replace($value, '', 0, $length); | |
break; | |
case 'generate_models_options': | |
$config['generate_models_options']['classPrefix'] = ucfirst($moduleName).'_Model_'; | |
break; | |
default: | |
break; | |
} | |
} | |
} | |
} | |
} | |
$cli = new Doctrine_Cli($config); | |
$cli->run($_SERVER['argv']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment