symfony i18n objects without output escaping

不打扰是莪最后的温柔 提交于 2019-12-24 07:03:04

问题


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 }

回答1:


Try:

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



回答2:


 $object->Translation['fr']->getDescription(ESC_RAW);

This should do the trick :)



来源:https://stackoverflow.com/questions/14988309/symfony-i18n-objects-without-output-escaping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!