public function restore(LdapObject $ldapObject, $location = null)
{
$event = new LdapObjectRestoreEvent(Event::LDAP_OBJECT_BEFORE_RESTORE, $ldapObject, $location);
$this->dispatcher->dispatch($event);
$location = $event->getContainer();
$this->validateObject($ldapObject);
$originalDn = $ldapObject->get('dn');
$ldapObject->reset('isDeleted');
// Some additional logic may be needed to get the actual restore location...
$newLocation = $this->getObjectRestoreLocation($ldapObject, $location);
// The DN contains the full RDN (including the preceding attribute name). The original RDN is before the \0A.
$rdn = explode('\\0A', $ldapObject->get('dn'), 2)[0];
$ldapObject->set('dn', "{$rdn},{$newLocation}");
$this->executeBatchOperation($ldapObject, $originalDn);
$this->dispatcher->dispatch(new LdapObjectRestoreEvent(Event::LDAP_OBJECT_AFTER_RESTORE, $ldapObject, $location));
}