Action and pass variable to all actions in symfony 1.4

后端 未结 2 1932
后悔当初
后悔当初 2021-01-26 18:43

I want to make some action (php script) before all actions in my frontend app and then pass a result from that script to actions in variable - so I can get variable value from a

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-26 19:01

    What kind of information ?

    I would recommend you to use filters.

    In your apps/frontend/config/filters.yml:

    rendering: ~
    myfilter:
      class: myCustomFilter
    

    Create the file lib/filter/myCustomFilter.php:

    isFirstCall())
        {
          // do what ever you want here.
          $config = Doctrine_Core::getTable('Config')->findAll();
          sfConfig::set('my_config', $config);
        }
    
        $filterChain->execute();
      }
    }
    

    And then, every where, you can retrieve your data:

    sfConfig::get('my_config');
    

提交回复
热议问题