The doctrine of postSave, postUpdate and internationalization (change detection)

I have a little problem with tables using i18n behavior in the Symfony 1.4 project that I am developing. For example, on the following model defined on YAML (I have others that follow the same pattern):

Subject:
  actAs:
    Timestampable: ~
    I18n:
      fields: [name]
  columns:
    name: { type: string(255), notnull: true }
  relations:
    Publications:
      class: Publication
      refClass: PublicationSubject
      local: subject_id
      foreign: publication_id

I have only a name field that is internationalized, but when saving (after changing one of the languages ​​in the form), the postUpdate ($ event) method does not start. I thought that I could use the postSave ($ event) method and check if it has changed, but it also always returns false. So, how can I determine if the internationalized doctrine model is modified?

Thanks in advance;)

+5
3

, , - i18n.

, , i18n symfony $record- > Translation, symfony - _set, (Subject) recordTranslation.

, saveEmbeddedForms (SubjectForm), i18n , , , , - , postSave .

public $already_saved;

  public function doSave($con = null) {
    $this->already_saved = $this->object->isModified();
    parent::doSave($con);
  }



public function saveEmbeddedForms($con = null,$forms = null){

if (null === $con)
  $con = $this->getConnection();


if (null === $forms)
  $forms = $this->embeddedForms;

foreach($forms as $form) {
  if  ( count($form->object->isModified()) != 0){ 
    $mark_for_save = true;
    break;
  }
}
parent::saveEmbeddedForms($con, $forms);
if (@$mark_for_save && !$this->already_saved) {
  $this->object->postSave();
}

  }
+1

$record->isModified();

, , .

$modified = $record->getModified();
if(isset($modified['fieldName']))
{
   //do something
}

,

0

Doctrine record interceptors (preInsert, postInsert, etc.) are not triggered when DQL or plain SQL is used to modify records.

I remember that they are not called in sfDoctrineObjectForm either, and you need to redefine methods in the form class, for example doSave, either add behavior or call them directly (the latter is much better than imho)

Hi,

0
source

All Articles