[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 3 /* 4 * This file is part of the symfony package. 5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 6 * 7 * For the full copyright and license information, please view the LICENSE 8 * file that was distributed with this source code. 9 */ 10 11 /** 12 * @package symfony 13 * @subpackage addon 14 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 15 * @version SVN: $Id: sfPropelBehavior.class.php 2453 2006-10-20 05:58:48Z fabien $ 16 */ 17 class sfPropelBehavior 18 { 19 static protected $behaviors = array(); 20 21 static public function registerMethods($name, $callables) 22 { 23 if (!isset(self::$behaviors[$name])) 24 { 25 self::$behaviors[$name] = array('methods' => array(), 'hooks' => array()); 26 } 27 foreach ($callables as $callable) 28 { 29 self::$behaviors[$name]['methods'][] = $callable; 30 } 31 } 32 33 static public function registerHooks($name, $hooks) 34 { 35 if (!isset(self::$behaviors[$name])) 36 { 37 self::$behaviors[$name] = array('methods' => array(), 'hooks' => array()); 38 } 39 foreach ($hooks as $hook => $callable) 40 { 41 if (!isset(self::$behaviors[$name]['hooks'])) 42 { 43 self::$behaviors[$name]['hooks'][$hook] = array(); 44 } 45 46 self::$behaviors[$name]['hooks'][$hook][] = $callable; 47 } 48 } 49 50 static public function add($class, $behaviors) 51 { 52 foreach ($behaviors as $name => $parameters) 53 { 54 if (is_int($name)) 55 { 56 // no parameters 57 $name = $parameters; 58 } 59 else 60 { 61 // register parameters 62 foreach ($parameters as $key => $value) 63 { 64 sfConfig::set('propel_behavior_'.$name.'_'.$class.'_'.$key, $value); 65 } 66 } 67 68 if (!isset(self::$behaviors[$name])) 69 { 70 throw new sfConfigurationException(sprintf('Propel behavior "%s" is not registered', $name)); 71 } 72 73 // register hooks 74 foreach (self::$behaviors[$name]['hooks'] as $hook => $callables) 75 { 76 foreach ($callables as $callable) 77 { 78 sfMixer::register('Base'.$class.$hook, $callable); 79 } 80 } 81 82 // register new methods 83 foreach (self::$behaviors[$name]['methods'] as $callable) 84 { 85 sfMixer::register('Base'.$class, $callable); 86 } 87 } 88 } 89 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |