LdapTools\Operation\Invoker\LdapOperationInvoker::executeOperation PHP Method

executeOperation() protected method

Execute a given operation with an operation handler.
protected executeOperation ( LdapTools\Operation\LdapOperationInterface $operation, LogOperation $log = null ) : mixed
$operation LdapTools\Operation\LdapOperationInterface
$log LdapTools\Log\LogOperation
return mixed
    protected function executeOperation(LdapOperationInterface $operation, LogOperation $log = null)
    {
        $lastServer = $this->connection->getServer();
        try {
            $this->connectIfNotBound($operation);
            $lastServer = $this->connection->getServer();
            $handler = $this->getOperationHandler($operation);
            $handler->setOperationDefaults($operation);
            $this->logStart($log);
            $this->switchServerIfNeeded($this->connection->getServer(), $operation->getServer(), $operation);
            $this->idleReconnectIfNeeded($operation);
            $this->setLdapControls($operation);
            return $handler->execute($operation);
        } catch (\Throwable $e) {
            $this->logExceptionAndThrow($e, $log);
        } catch (\Exception $e) {
            $this->logExceptionAndThrow($e, $log);
        } finally {
            $this->logEnd($log);
            $this->resetLdapControls($operation);
            $this->switchServerIfNeeded($this->connection->getServer(), $lastServer, $operation);
            $this->dispatcher->dispatch(new LdapOperationEvent(Event::LDAP_OPERATION_EXECUTE_AFTER, $operation, $this->connection));
        }
    }