LdapTools\Object\LdapObjectManager::move PHP Method

move() public method

Moves an object from one container/OU to another in LDAP.
public move ( LdapObject $ldapObject, string $container )
$ldapObject LdapObject
$container string
    public function move(LdapObject $ldapObject, $container)
    {
        $event = new LdapObjectMoveEvent(Event::LDAP_OBJECT_BEFORE_MOVE, $ldapObject, $container);
        $this->dispatcher->dispatch($event);
        $container = $event->getContainer();
        $this->validateObject($ldapObject);
        $operation = new RenameOperation($ldapObject->get('dn'), LdapUtilities::getRdnFromDn($ldapObject->get('dn')), $container, true);
        $this->connection->execute($operation);
        // Update the object to reference the new DN after the move...
        $newDn = LdapUtilities::getRdnFromDn($ldapObject->get('dn')) . ',' . $container;
        $ldapObject->refresh(['dn' => $newDn]);
        $ldapObject->getBatchCollection()->setDn($newDn);
        $this->dispatcher->dispatch(new LdapObjectMoveEvent(Event::LDAP_OBJECT_AFTER_MOVE, $ldapObject, $container));
    }