symfony i18n对象没有输出转义 [英] symfony i18n objects without output escaping

查看:178
本文介绍了symfony i18n对象没有输出转义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在Symfony 1.4和Doctrine中遇到问题,而不用输出i18n对象的价值。 > $ object-> getDescription(ESC_RAW); 以获取未转义的值。当我想要获得对象的特定翻译时出现问题。如何指定文化和转义策略?我没有找到任何有关这方面的文件。我可以传递多个参数作为数组或类似的东西: $ object-> getDescription(array('fr',ESC_RAW));



这是我的架构的相关部分:

 对象:
actAs:
时间戳:〜
I18n:
字段:[名称,描述]
列:
名称:{type:string(255),notnull:true}
描述:{t​​ype:string(1000)}
user_id:{type:integer}
关系:
用户:{class:sfGuardUser,local:user_id,foreign:id,type:一个,foreignType:many,foreignAlias:Objects}


解决方案

  sfOutputEscaper :: unescape($ object-> Translation ['fr']  - > description); 


I am having a problem in Symfony 1.4 and Doctrine with getting the value of an i18n object without output escaping.

Typically I just do this $object->getDescription(ESC_RAW); to get the value un-escaped. The problem comes in when I want to get a specific translation of the object. How do I specify the culture and the escaping strategy? I haven't found any documentation on this. Can I pass multiple parameters as an array or something similar to this: $object->getDescription(array('fr', ESC_RAW));?

Here's the relevant portion of my schema:

Object:
  actAs:
    Timestampable: ~
    I18n:
      fields:           [name, description]
  columns:
    name:               { type: string(255), notnull: true }
    description:        { type: string(1000) }
    user_id:            { type: integer }
  relations:
    User:               { class: sfGuardUser, local: user_id, foreign: id, type: one, foreignType: many, foreignAlias: Objects }

解决方案

Try:

sfOutputEscaper::unescape($object->Translation['fr']->description);

这篇关于symfony i18n对象没有输出转义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆