dans mon app_model j'ai mis :

public static $puncake_behaviors = array();

        public function addBehavior($behavior,$func)
        {
            echo "add behavior : $behavior funtion : $func<br/>";
                if (is_callable($func)) {
                    echo "la fonction est appelable<br/>";
                        #$this->puncake_behaviors[$behavior][] = $func;
                        self::$puncake_behaviors[$behavior][] = $func;
        echo "<pre>";
        #print_r($this->puncake_behaviors);
        print_r(self::$puncake_behaviors);
        echo "</pre>";
                }
        }

        public function callBehavior($behavior)
        {
        echo "j'appelle le behavior $behavior<br/>";
        echo "<pre>";
        #print_r($this->puncake_behaviors);
        print_r(self::$puncake_behaviors);
        echo "</pre>";
                if (!empty((self::$puncake_behaviors[$behavior]))
                {

                        $args = func_get_args();
                        array_shift($args);

                        $res = '';

                        foreach ($this->puncake_behaviors[$behavior] as $f) {
                                $res .= call_user_func_array($f,$args);
                        }

                        return $res;
                }
        }

affiche "j'appelle le behavior adminIndexHTML" puis mon array ....
vide ... :(



On 29 mar, 19:23, "Mehdi AMINI" <[EMAIL PROTECTED]> wrote:
> >  Donc je cherche un moyen d'avoir mon array puncake_behaviors "global"
> >  à toute mon appli ainsi que callBehavior.
>
> C'est pas justement l'objet du mot clef 'static' ? D'avoir des
> attributs de classe ?
>
> ça doit donner un truc du genre en php5,  dans AppModel :
>
>      static var $puncake_behaviors;
>
> Le reste identique.
> En php4 c'est plus sioux, 
> cfhttp://php.developpez.com/faq/?page=poo-php4#poo-php4-staticvar
>
> Mehdi
--~--~---------~--~----~------------~-------~--~----~

Groupe "Cakephp-fr".
Adresse : [email protected]
Pour résilier  : [EMAIL PROTECTED]
Pour les options : http://groups.google.com/group/cakephp-fr?hl=fr
-~----------~----~----~----~------~----~------~--~---

Répondre à