2014-01-12 5 views
0

Symfony 2.4 및 doctrine ORM을 사용하고 있습니다. 나는 부모 개체를 포함하여 많은 자식 관계를 가지고 속성 :의 lastUpdated 필드에서엔터티 또는 해당 관계가 업데이트되었을 때의 추적

  • propertyVideos (OneToMany)
  • propertyPhotos (OneToMany)
  • propertyLocation (OneToOne)

Property 엔터티 또는 관련된 엔티티 중 하나 인의 마지막 업데이트 날짜와 시간을 저장해야합니다.

Symfony/Doctrine에서 이것을 쉽게 할 수있는 방법이 있습니까?

답변

0

가장 쉬운 건 oneToMany 관계의 변화를 추적 대한 gedmo/doctrine-extensions 또는 후 다음 작업을 수행 할 수 있습니다 stof/doctrine-extensions-bundle (심포니) ... 답장을

Entity\Article: 
    type: entity 
    table: articles 
    fields: 
     created: 
      type: date 
      gedmo: 
       timestampable: 
        on: create // $this create 
     updated: 
      type: datetime 
      gedmo: 
       timestampable: 
        on: update // $this update 
     published: 
      type: datetime 
      gedmo: 
       timestmpable: 
        on: change 
        field: type.title 
        value: Published 
           // $this->type->title changed to "Published" 
     blah: 
      type: datetime 
      gedmo: 
       timestampable: 
        on: change 
        field: type.somethingelse 
           // $this->type.somethingelse is changed 
    manyToOne: 
     type: 
      targetEntity: Entity\Type 
      inversedBy: articles 
+0

감사합니다,하지만를 사용하는 것 ? 어떻게 처리 될까요? – user3009816

+0

@ user3009816 동일한 것을 찾고 있었지만 교리 리스너 나 라이프 사이클 이벤트를 사용하여 수동으로 처리해야합니다. [here] (https://github.com/Atlantic18/DoctrineExtensions/issues/1435) 번들 작성자 – lolmx

관련 문제