| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
require_once dirname(__FILE__).'/../../../../../../autoload/sfCoreAutoload.class.php';
|
|
|
4 |
sfCoreAutoload::register();
|
|
|
5 |
|
|
|
6 |
class ProjectConfiguration extends sfProjectConfiguration
|
|
|
7 |
{
|
|
|
8 |
public function setup()
|
|
|
9 |
{
|
|
|
10 |
$this->enableAllPluginsExcept(array('sfDoctrinePlugin'));
|
|
|
11 |
}
|
|
|
12 |
|
|
|
13 |
public function initializePropel($app)
|
|
|
14 |
{
|
|
|
15 |
// build Propel om/map/sql/forms
|
|
|
16 |
$files = glob(sfConfig::get('sf_lib_dir').'/model/om/*.php');
|
|
|
17 |
if (false === $files || !count($files))
|
|
|
18 |
{
|
|
|
19 |
chdir(sfConfig::get('sf_root_dir'));
|
|
|
20 |
$task = new sfPropelBuildModelTask($this->dispatcher, new sfFormatter());
|
|
|
21 |
ob_start();
|
|
|
22 |
$task->run();
|
|
|
23 |
$output = ob_get_clean();
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
$files = glob(sfConfig::get('sf_data_dir').'/sql/*.php');
|
|
|
27 |
if (false === $files || !count($files))
|
|
|
28 |
{
|
|
|
29 |
chdir(sfConfig::get('sf_root_dir'));
|
|
|
30 |
$task = new sfPropelBuildSqlTask($this->dispatcher, new sfFormatter());
|
|
|
31 |
ob_start();
|
|
|
32 |
$task->run();
|
|
|
33 |
$output = ob_get_clean();
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
$files = glob(sfConfig::get('sf_lib_dir').'/form/base/*.php');
|
|
|
37 |
if (false === $files || !count($files))
|
|
|
38 |
{
|
|
|
39 |
chdir(sfConfig::get('sf_root_dir'));
|
|
|
40 |
$task = new sfPropelBuildFormsTask($this->dispatcher, new sfFormatter());
|
|
|
41 |
$task->run(array(), array('application='.$app));
|
|
|
42 |
}
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
public function loadFixtures($fixtures)
|
|
|
46 |
{
|
|
|
47 |
// initialize database manager
|
|
|
48 |
$databaseManager = new sfDatabaseManager($this);
|
|
|
49 |
|
|
|
50 |
// cleanup database
|
|
|
51 |
$db = sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'/database.sqlite';
|
|
|
52 |
if (file_exists($db))
|
|
|
53 |
{
|
|
|
54 |
unlink($db);
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
// initialize database
|
|
|
58 |
$sql = file_get_contents(sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'sql'.DIRECTORY_SEPARATOR.'lib.model.schema.sql');
|
|
|
59 |
$sql = preg_replace('/^\s*\-\-.+$/m', '', $sql);
|
|
|
60 |
$sql = preg_replace('/^\s*DROP TABLE .+?$/m', '', $sql);
|
|
|
61 |
$con = Propel::getConnection();
|
|
|
62 |
$tables = preg_split('/CREATE TABLE/', $sql);
|
|
|
63 |
foreach ($tables as $table)
|
|
|
64 |
{
|
|
|
65 |
$table = trim($table);
|
|
|
66 |
if (!$table)
|
|
|
67 |
{
|
|
|
68 |
continue;
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
$con->query('CREATE TABLE '.$table);
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
// load fixtures
|
|
|
75 |
$data = new sfPropelData();
|
|
|
76 |
if (is_array($fixtures))
|
|
|
77 |
{
|
|
|
78 |
$data->loadDataFromArray($fixtures);
|
|
|
79 |
}
|
|
|
80 |
else
|
|
|
81 |
{
|
|
|
82 |
$data->loadData(sfConfig::get('sf_data_dir').'/'.$fixtures);
|
|
|
83 |
}
|
|
|
84 |
}
|
|
|
85 |
}
|