| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
class sfPropelPluginConfiguration extends sfPluginConfiguration |
|---|
| 12 |
{ |
|---|
| 13 |
|
|---|
| 14 |
* @see sfPluginConfiguration |
|---|
| 15 |
*/ |
|---|
| 16 |
public function initialize() |
|---|
| 17 |
{ |
|---|
| 18 |
sfConfig::set('sf_orm', 'propel'); |
|---|
| 19 |
if (!sfConfig::get('sf_admin_module_web_dir')) |
|---|
| 20 |
{ |
|---|
| 21 |
sfConfig::set('sf_admin_module_web_dir', '/sfPropelPlugin'); |
|---|
| 22 |
} |
|---|
| 23 |
|
|---|
| 24 |
sfToolkit::addIncludePath(array( |
|---|
| 25 |
sfConfig::get('sf_root_dir'), |
|---|
| 26 |
sfConfig::get('sf_propel_runtime_path', realpath(dirname(__FILE__).'/../lib/vendor')), |
|---|
| 27 |
)); |
|---|
| 28 |
|
|---|
| 29 |
require_once 'propel/Propel.php'; |
|---|
| 30 |
|
|---|
| 31 |
if (!Propel::isInit()) |
|---|
| 32 |
{ |
|---|
| 33 |
if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) |
|---|
| 34 |
{ |
|---|
| 35 |
Propel::setLogger(new sfPropelLogger($this->dispatcher)); |
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
$propelConfiguration = new PropelConfiguration(); |
|---|
| 39 |
Propel::setConfiguration($propelConfiguration); |
|---|
| 40 |
|
|---|
| 41 |
$this->dispatcher->notify(new sfEvent($propelConfiguration, 'propel.configure')); |
|---|
| 42 |
|
|---|
| 43 |
Propel::initialize(); |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
$this->dispatcher->connect('user.change_culture', array('sfPropel', 'listenToChangeCultureEvent')); |
|---|
| 47 |
|
|---|
| 48 |
if (sfConfig::get('sf_web_debug')) |
|---|
| 49 |
{ |
|---|
| 50 |
$this->dispatcher->connect('debug.web.load_panels', array('sfWebDebugPanelPropel', 'listenToAddPanelEvent')); |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
if (sfConfig::get('sf_test')) |
|---|
| 54 |
{ |
|---|
| 55 |
$this->dispatcher->connect('context.load_factories', array($this, 'clearAllInstancePools')); |
|---|
| 56 |
} |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
* Clears all instance pools. |
|---|
| 61 |
* |
|---|
| 62 |
* This method is used to clear Propel's static instance pools between |
|---|
| 63 |
* requests performed in functional tests. |
|---|
| 64 |
*/ |
|---|
| 65 |
public function clearAllInstancePools() |
|---|
| 66 |
{ |
|---|
| 67 |
$finder = sfFinder::type('file')->name('*TableMap.php'); |
|---|
| 68 |
foreach ($finder->in($this->configuration->getModelDirs()) as $file) |
|---|
| 69 |
{ |
|---|
| 70 |
$omClass = basename($file, 'TableMap.php'); |
|---|
| 71 |
if (class_exists($omClass) && is_subclass_of($omClass, 'BaseObject')) |
|---|
| 72 |
{ |
|---|
| 73 |
$peer = constant($omClass.'::PEER'); |
|---|
| 74 |
call_user_func(array($peer, 'clearInstancePool')); |
|---|
| 75 |
} |
|---|
| 76 |
} |
|---|
| 77 |
} |
|---|
| 78 |
} |
|---|
| 79 |
|
|---|