symfony i18n objects without output escaping

2019-07-24 18:57发布

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 }

2条回答
Ridiculous、
2楼-- · 2019-07-24 19:59

Try:

sfOutputEscaper::unescape($object->Translation['fr']->description);
查看更多
我只想做你的唯一
3楼-- · 2019-07-24 20:02
 $object->Translation['fr']->getDescription(ESC_RAW);

This should do the trick :)

查看更多
登录 后发表回答