_entityPersister = $entityPersister; $this->_identifier = $identifier; } /** @private */ public function __load() { if (!$this->__isInitialized__ && $this->_entityPersister) { $this->__isInitialized__ = true; if (method_exists($this, "__wakeup")) { // call this after __isInitialized__to avoid infinite recursion // but before loading to emulate what ClassMetadata::newInstance() // provides. $this->__wakeup(); } if ($this->_entityPersister->load($this->_identifier, $this) === null) { throw new \Doctrine\ORM\EntityNotFoundException(); } unset($this->_entityPersister, $this->_identifier); } } /** @private */ public function __isInitialized() { return $this->__isInitialized__; } public function getId() { if ($this->__isInitialized__ === false) { return (int) $this->_identifier["id"]; } $this->__load(); return parent::getId(); } public function getUsrId() { $this->__load(); return parent::getUsrId(); } public function setUsrId($usrId) { $this->__load(); return parent::setUsrId($usrId); } public function getUser() { $this->__load(); return parent::getUser(); } public function setUser(\Alchemy\Phrasea\Model\Entities\User $user = NULL) { $this->__load(); return parent::setUser($user); } public function getQuery() { $this->__load(); return parent::getQuery(); } public function setQuery($query) { $this->__load(); return parent::setQuery($query); } public function getCreated() { $this->__load(); return parent::getCreated(); } public function setCreated(\DateTime $created) { $this->__load(); return parent::setCreated($created); } public function __sleep() { return array('__isInitialized__', 'id', 'usrId', 'query', 'created', 'user'); } public function __clone() { if (!$this->__isInitialized__ && $this->_entityPersister) { $this->__isInitialized__ = true; $class = $this->_entityPersister->getClassMetadata(); $original = $this->_entityPersister->load($this->_identifier); if ($original === null) { throw new \Doctrine\ORM\EntityNotFoundException(); } foreach ($class->reflFields as $field => $reflProperty) { $reflProperty->setValue($this, $reflProperty->getValue($original)); } unset($this->_entityPersister, $this->_identifier); } } }