65 lines
1.6 KiB
PHP
65 lines
1.6 KiB
PHP
<?php
|
|
// --- Define path to application directory
|
|
defined('APPLICATION_PATH')
|
|
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
|
|
|
|
// --- Define application environment
|
|
defined('APPLICATION_ENV')
|
|
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
|
|
|
// --- Composer autoload
|
|
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
|
|
|
|
// --- Create application, bootstrap, and run
|
|
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
|
|
|
$displayUsage = false;
|
|
try {
|
|
$opts = new Zend_Console_Getopt(
|
|
//Options
|
|
array(
|
|
'help|?' => "Aide.",
|
|
'compile-s' => "Génére le cache des règles, sans paramètres (tout), avec paramètres (VORD, VORP, PO)",
|
|
'version=s' => "Version des régles",
|
|
)
|
|
);
|
|
$opts->parse();
|
|
} catch (Zend_Console_Getopt_Exception $e) {
|
|
$displayUsage = true;
|
|
}
|
|
|
|
// --- Aide / Options
|
|
if (count($opts->getOptions())==0 || isset($opts->help)) {
|
|
$displayUsage = true;
|
|
}
|
|
|
|
// --- Usage
|
|
if ($displayUsage) {
|
|
echo "\nRegles SFR\n\n";
|
|
echo $opts->getUsageMessage();
|
|
exit;
|
|
}
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
$db = Zend_Db::factory($c->profil->db->metier);
|
|
Zend_Db_Table::setDefaultAdapter($db);
|
|
|
|
$types = array('VORD', 'VORP', 'PO');
|
|
|
|
if ( $opts->compile!='' && in_array($opts->compile, $types) ) {
|
|
$types = array($opts->compile);
|
|
}
|
|
|
|
if ( count($types) > 0 ) {
|
|
|
|
foreach ( $types as $type ) {
|
|
$ruleSfrM = new SdMetier_Sfr_Compile();
|
|
$ruleSfrM->setVersion($opts->version);
|
|
$ruleSfrM->construct($type);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|