public function doctrineAction()
 {
     $options = array('phpDocPackage' => 'Kromatick', 'phpDocSubpackage' => 'Intermodels', 'phpDocName' => 'Neozeratul', 'phpDocEmail' => '*****@*****.**');
     Doctrine::dropDatabases();
     Doctrine::createDatabases();
     Doctrine::generateModelsFromYaml(APPLICATION_PATH . "/data/schema/schema.yml", APPLICATION_PATH . "/models", $options);
     Doctrine::createTablesFromModels();
     //Doctrine::loadData($yamlPath, $append):
     echo Doctrine::generateSqlFromModels();
     $this->render('index');
 }
Example #2
0
 public function execute()
 {
     Doctrine::generateModelsFromYaml($this->getArgument('yaml_schema_path'), $this->getArgument('models_path'), $this->getArgument('generate_models_options', array()));
     $this->notify('Generated models successfully from YAML schema');
 }
Example #3
0
 * @author     Dejan Spasic <*****@*****.**>
 * @version    SVN: $Id: bootstrap.php 20057 2009-07-09 13:40:40Z Dejan.Spasic $
 */
// Autofind the first available app environment
$sfRootDir = realpath(dirname(__FILE__) . '/../../../');
$appsDir = glob($sfRootDir . '/apps/*', GLOB_ONLYDIR);
$app = substr($appsDir[0], strrpos($appsDir[0], DIRECTORY_SEPARATOR) + 1, strlen($appsDir[0]));
if (!$app) {
    throw new Exception('No app has been detected in this project');
}
// -- path to the symfony project where the plugin resides
$sfPath = dirname(__FILE__) . '/../../..';
// bootstrap
include $sfPath . '/test/bootstrap/unit.php';
// initialize database manager
new sfDatabaseManager(ProjectConfiguration::getActive());
// initialize database connection for our tests
Doctrine_Manager::connection('sqlite::memory:', '_test_graphiz');
// clean the model directory
try {
    $_fs = new sfFilesystem();
    $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/_files/model'), RecursiveIteratorIterator::CHILD_FIRST);
    foreach ($it as $file) {
        $_fs->remove($file->getPathname());
    }
    $_fs->remove(dirname(__FILE__) . '/_files/model');
} catch (Exception $e) {
}
// generate the model
Doctrine::generateModelsFromYaml(dirname(__FILE__) . '/_files', dirname(__FILE__) . '/_files/model');
/**
 * Generates Models from YAML Schema file
 * @param string $name
 */
function doctrine_create_models($name = NULL)
{
    if ($name === NULL) {
        $location = SCHEMA_DIRECTORY;
    } else {
        $location = SCHEMA_DIRECTORY . $name;
    }
    Doctrine::generateModelsFromYaml($location, MODELS_DIRECTORY);
}
Example #5
0
<?php

define("CLASSPATH", realpath(dirname(__FILE__) . "/../.."));
define("DOCTRINE_FOLDER", CLASSPATH . "/3rdParty/Doctrine-1.1.0/lib");
define("MODELS_FOLDER", CLASSPATH . "/models/data_objects");
define("YML_FOLDER", CLASSPATH . "/models/yml");
require_once DOCTRINE_FOLDER . '/Doctrine.php';
require_once CLASSPATH . '/config/db.conf.php';
spl_autoload_register(array('Doctrine', 'autoload'));
$manager = Doctrine_Manager::getInstance();
$conn = Doctrine_Manager::connection("{$db_conn_type}://{$db_user}:{$db_pass}@{$db_host}/{$db_name}", 'doctrine');
$manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
$conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true);
Doctrine::dropDatabases();
Doctrine::createDatabases();
Doctrine::generateModelsFromYaml(YML_FOLDER . '/db.yml', MODELS_FOLDER);
Doctrine::createTablesFromModels(MODELS_FOLDER);
<?php

/**
 * Script for creating and loading database
 */
include_once dirname(__FILE__) . '/../../../application/bootstrap.php';
echo 'Generating models from schemas' . PHP_EOL;
try {
    Doctrine::generateModelsFromYaml('user.yml', APPLICATION_PATH . '/models');
    Doctrine::createTablesFromArray(array('User'));
} catch (Exception $e) {
    echo 'AN ERROR HAS OCCURED:' . PHP_EOL;
    echo $e->getMessage() . PHP_EOL;
    return false;
}
// Generally speaking, this script will be run from the command line
return true;
Example #7
0
 /**
  * Generate a set of models for the schema information source
  *
  * @param  string $prefix  Prefix to generate the models with
  * @param  mixed  $item    The item to generate the models from
  * @return string $path    The path where the models were generated
  * @throws Doctrine_Migration_Exception $e
  */
 protected function _generateModels($prefix, $item)
 {
     $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . strtolower($prefix) . '_doctrine_tmp_dirs';
     $options = array('classPrefix' => $prefix);
     if (is_string($item) && file_exists($item)) {
         if (is_dir($item)) {
             $files = glob($item . DIRECTORY_SEPARATOR . '*.*');
         } else {
             $files = array($item);
         }
         if (isset($files[0])) {
             $pathInfo = pathinfo($files[0]);
             $extension = $pathInfo['extension'];
         }
         if ($extension === 'yml') {
             Doctrine::generateModelsFromYaml($item, $path, $options);
             return $path;
         } else {
             if ($extension === 'php') {
                 Doctrine_Lib::copyDirectory($item, $path);
                 return $path;
             } else {
                 throw new Doctrine_Migration_Exception('No php or yml files found at path: "' . $item . '"');
             }
         }
     } else {
         try {
             Doctrine::generateModelsFromDb($path, (array) $item, $options);
             return $path;
         } catch (Exception $e) {
             throw new Doctrine_Migration_Exception('Could not generate models from connection: ' . $e->getMessage());
         }
     }
 }
Example #8
0
$manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL);
//Le digo a doctrine que realice todas las validaciones de integridad: valores nulos, constrains, etc.
$manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
//Permito los override en las clases
$manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
if ($GLOBALS["BDLazyMode"]) {
    $manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
} else {
    $manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_AGGRESSIVE);
}
//Cargo todo el modelo
if (file_exists('../../model/generated')) {
    Doctrine::loadModels('../../model/generated');
} else {
    if ($GLOBALS["debugMode"]) {
        echo "No se ha encontrador el directorio 'model/generated'";
    }
}
if (file_exists('../../model')) {
    Doctrine::loadModels('../../model');
} else {
    if ($GLOBALS["debugMode"]) {
        echo "No se ha encontrador el directorio 'model'";
    }
}
//Debo hace un aggressive loadin de manera obligarotia, sino no se cargan todas las clases
$manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_AGGRESSIVE);
Doctrine::dropDatabases();
Doctrine::createDatabases();
Doctrine::generateModelsFromYaml('../../schema.yml', '../../model');
Example #9
0
<?php

require_once '../Plans.php';
Doctrine::generateModelsFromYaml('../db/schema.yaml', '../db/');