저는 StofDoctrineExtensionsBundle (와 Gedmo DoctrineExtensions)에서 Symfony2.2를 사용하고 있습니다. 기존 개체의 속성을 변경할 때 나는 간단한 개체Gedmo Loggable은 변경되지 않은 데이터를 기록합니다.
/**
* @ORM\Entity
* @Gedmo\Loggable
* @ORM\Table(name="person")
*/
class Person {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
[...]
/**
* @ORM\Column(type="datetime", nullable=true)
* @Assert\NotBlank()
* @Assert\Date()
* @Gedmo\Versioned
*/
protected $birthdate;
}
을했습니다, 로그 항목은 테이블 ext_log_entries
에서 이루어집니다. 이 로그 테이블의 항목에는 변경된 컬럼 만 들어 있습니다. 나는하여 로그를 읽을 수 있습니다 :
$em = $this->getManager();
$repo = $em->getRepository('Gedmo\Loggable\Entity\LogEntry');
$person_repo = $em->getRepository('Acme\MainBundle\Entity\Person');
$person = $person_repo->find(1);
$log = $repo->findBy(array('objectId' => $person->getId()));
foreach ($log as $log_entry) { var_dump($log_entry->getData()); }
그러나 필드 birthdate
항상 심지어는 변경되지 것, 로그 항목에 포함 된 이유를 내가 이해하지 못하는 것은입니다. 다음은 세 가지 로그 항목의 예입니다.
array(9) {
["salutation"]=>
string(4) "Herr"
["firstname"]=>
string(3) "Max"
["lastname"]=>
string(6) "Muster"
["street"]=>
string(14) "Musterstraße 1"
["zipcode"]=>
string(5) "00000"
["city"]=>
string(12) "Musterhausen"
["birthdate"]=>
object(DateTime)#655 (3) {
["date"]=>
string(19) "1893-01-01 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(13) "Europe/Berlin"
}
["email"]=>
string(17) "[email protected]"
["phone"]=>
NULL
}
array(2) {
["birthdate"]=>
object(DateTime)#659 (3) {
["date"]=>
string(19) "1893-01-01 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(13) "Europe/Berlin"
}
["phone"]=>
string(9) "123456789"
}
array(2) {
["birthdate"]=>
object(DateTime)#662 (3) {
["date"]=>
string(19) "1893-01-01 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(13) "Europe/Berlin"
}
["phone"]=>
NULL
}
정말 변경된 데이터 만 기록하고 싶습니다. 아직 보지 못했던 옵션이 있습니까? 사실 birthdate
은 DateTime
개체와 관련이있는 것 같습니다. 그렇습니까?
편집 DateTime
개체와 관련이 없습니다. 이것은 다른 엔티티에서도 발생합니다.
/**
* @ORM\Entity
* @Gedmo\Loggable
* @ORM\Entity(repositoryClass="Acme\MainBundle\Repository\ApplicationRepository")
* @ORM\Table(name="application")
*/
class Application {
[...]
/**
* @ORM\Column(type="integer")
* @Assert\NotBlank(groups={"FormStepOne", "UserEditApplication"})
* @Gedmo\Versioned
*/
protected $insurance_number;
}
수정없이 브라우저에서 편집 양식에게 절약을 열고, 로그 테이블이 포함되어 있습니다 :
update 2013-04-26 11:32:42 Acme\MainBundle\Entity\Application a:1:{s:16:"insurance_number";s:7:"1234567";}
update 2013-04-26 11:33:17 Acme\MainBundle\Entity\Application a:1:{s:16:"insurance_number";s:7:"1234567";}
이유는 다른 엔티티는 간단한 값을 포함하는거야?
심지어 오래된 질문이기도하다. 내 자신의 알림 기능을 구현하지 않기로 결정한이 진절머리 나는 행동을 시작했다. ( – rabudde
@rabudde Doctrine의 잘못이 아니라 PHP의 진부한 객체 비교 – calumbrodie
아 PHP의 잘못이기도합니다.하지만 PHP를 기반으로하는 응용 프로그램의 번들/플러그인을 작성하는 경우 객체 자체를 비교하는 것이 어려울 것이라고 상상할 수는 없지만 Gedmo 번들을 해킹하지는 않습니다. 그럼에도 불구하고 당신의 대답에 감사드립니다. – rabudde