2010年5月25日 星期二

Some notes for symfony

View Template Shortcuts

  • $sf_context: The whole context object (instance of sfContext)
  • $sf_request: The request object (instance of sfRequest) 
  • $sf_params: Parameters of the request 
  • $sf_user: The current user session object (instance of sfUser)

      Get XML information in symfony 1.4

      When parse a remote xml file, I use sfWebBrowserPlugin and get the right result, like this way:

      in actions code
      $tar = new sfWebBrowser();
      $tar->post(url_for('MsgTransfer/Recommender', true), http_build_query($this->form->getValues()));
      $this->xml = $tar->getResponseXML(); 
      
      in template code
      php echo $xml->string;
      then i get the error message:
      Fatal error: Call to undefined method SimpleXMLElement::__toString() in /usr/share/php/symfony/escaper/sfOutputEscaperObjectDecorator.class.php on line 98

      The solution to solve is use:
      php echo $sf_data->getRaw('xml')->string;
      

      0 意見: