symfony 1.4 + Propel ã® DBã¬ããªã±ã¼ã·ã§ã³ã§ä»»æã®ã¿ã¤ãã³ã°ã§ãã¹ã¿æ¥ç¶ã«åãæ¿ãã
ãã¼ã¿æ´æ°å¾ã¯ãã¹ã¿ã«æ¥ç¶ãã
app.yml
all: propel: force_master_flashes: [notice]
frontendConfiguration.class.php
<?php public function configure() { $this->dispatcher->connect('context.load_factories', array($this, 'loadFactoriesEvent')); } public function loadFactoriesEvent(sfEvent $event) { $user = $event->getSubject()->getUser(); foreach (sfConfig::get('app_propel_force_master_flashes') as $name) { if ($user->hasFlash($name)) { Propel::setForceMasterConnection(true); break; } } }
ç¹å®ã®ã¢ã¯ã·ã§ã³ã§ã¯å¸¸ã«ãã¹ã¿ã«æ¥ç¶ãã
app.yml
all: propel: force_master_actions: - [module, action]
frontendConfiguration.class.php
<?php public function configure() { $this->dispatcher->connect('controller.change_action', array($this, 'changeActionEvent')); } public function changeActionEvent(sfEvent $event) { $mod_act = array($event['module'], $event['action']); if (in_array($mod_act, sfConfig::get('app_propel_force_master_actions'))) { Propel::setForceMasterConnection(true); } }