开发者

Overwrite doctrine setters when we are using i18n actAs

开发者 https://www.devze.com 2023-03-15 07:54 出处:网络
I want know if is possible (and how?) overwrite doctrine setters when we use i18n actAs... I\'m trying something like this:

I want know if is possible (and how?) overwrite doctrine setters when we use i18n actAs...

I'm trying something like this:

class Category extends BaseCategory
{
    /*
     * Overwrite save method
     */
    public function save(Doctrine_Connection $conn = null)
    {
        $conn = $conn ? $conn : $this->getTable()->getConnection();

        开发者_Python百科$conn->beginTransaction();
        try
        {
            $this->setSlug();

            $ret = parent::save($conn);
            $conn->commit();

            return $ret;
        }
        catch (Exception $e)
        {
            $conn->rollBack();
            throw $e;
        }
    }

    public function setSlug()
    {
        $slug = $this->getName() . 'lala lala';
        parent::_set('slug', $slug);
    }
.....

But only save the $slug value in one lang (I have 2 languages).

Any Idea??

Thanks A Lot!


Thanks for replaying. I solved it like this:

$cultures = sfConfig::get('app_cultures');

      // seteamos slug
      foreach($cultures as $culture)
      {
          parent::_set('slug', 'lala lala');
      } ...


You can simply loop through the translations:

foreach($this->Translations as $lang => $t) {
  $t->slug = $t->name.'lala';
}
0

精彩评论

暂无评论...
验证码 换一张
取 消