@param Model\InStore\Invite $invite
@param HandlerStack|null    $stack

@return bool
481939
public function invite(Model\InStore\Invite $invite, HandlerStack $stack = null)
    {
        try {
            $params = $this->generateParams($invite, $stack);

            $this->getClient()->post(
                'invite',
                $params
            );
        } catch (BadResponseException $e) {
            throw new ApiException(
                $this->getSerializer()->deserialize(
                    (string) $e->getResponse()->getBody(),
                    ErrorResponse::class,
                    'json'
                ),
                $e
            );
        }

        return true;
    }
708044
public function deleted(MemberInvitation $invitation)
    {
        $member = Member::findOrFail($invitation->member_id);
        /** @noinspection PhpUndefinedMethodInspection */
        $member->forceDelete();
    }
949591
public function add($eventName, $eventHandler, $key = null) {
        if (!is_callable($eventHandler)) {
            throw new \Exception('Function is expected.');
        }

        if ($key !== null) {
            $this->{$eventName}[$key] = $eventHandler;
        }
        else {
            $this->{$eventName}[] = $eventHandler;
        }
    }
1165818
public function addInvitation(Invitation $invitation): self
    {
        $invitation->setEvent($this);
        $this->invitations[] = $invitation;

        return $this;
    }
92732
function pushState(stack, type, instance) {
  stack.type = type;
  stack.children = [];
  stack.instance = instance || stack;
}
529064
public function acquireCounteragentWithDocument($myOrgId, $counteragentOrgId, $myDepartmentId, InvitationDocument $invitationDocument = null, $messageToContragent = null)
    {
        $request = new AcquireCounteragentRequest();
        $request->setOrgId($counteragentOrgId);
        $request->setMessageToCounteragent($messageToContragent);
        $request->setInvitationDocument($invitationDocument);

        $response = $this->doRequest(
            self::RESOURCE_ACQUIRE_COUNTERAGENTS_V2,
            [
                'myOrgId' => $myOrgId,
                'myDepartmentId'    =>  $myDepartmentId,
            ],
            self::METHOD_POST,
            $request->toStream()->getContents()
        );
        return AsyncMethodResult::fromStream($response);
    }
1205992
protected function addMiddlewareChain(
        Closure $handler,
        PsrContainerInterface $container,
        array $globalMiddleware,
        array $routeMiddleware = null
    ): Closure {
        $handler = $this->createMiddlewareChainImpl($handler, $container, $routeMiddleware);
        $handler = $this->createMiddlewareChainImpl($handler, $container, $globalMiddleware);

        return $handler;
    }
812979
public function callMiddlewareStack(ServerRequestInterface $request, ResponseInterface $response)
    {

        if (!$this->tip) {
            $this->seedMiddlewareStack();
        }

        $this->deferredBefore = new \SplObjectStorage();
        $this->deferredAfter  = new \SplObjectStorage();

        $this->callableStackBefore->rewind();
        $this->callableStackAfter->rewind();
    
        $before = null;

        if (!$this->callableStackBefore->isEmpty()) {
            $before = $this->callableStackBefore->dequeue();
        }
        
        $after = null;

        if (!$this->callableStackAfter->isEmpty()) {
            $after = $this->callableStackAfter->dequeue();
        }

        $this->middlewareLock = true;

        if ($before) {
            list ($request, $response) = $before($request, $response);
        }
        
        $response = call_user_func($this->tip, $request, $response);
        
        //
        if ($after) {
            list ($request, $response) = $after($request, $response);
        }
        
        $this->middlewareLock = false;

        return $response;
    }
1016481
public function process(RequestInterface $request, HandlerInterface $handler)
    {
        $this->stack[] = new LastMiddleware($handler);

        $response = $this->dispatch($request);

        unset($this->stack[count($this->stack) - 1]);

        return $response;
    }
762679
public function createStack($handlers): Stack
    {
        if (!is_array($handlers)) {
            $handlers = [$handlers];
        }
        return new Stack(
            $handlers,
            $this->handlerResolver
        );
    }
1232025
private function resolve(array $stack, int $index) : RequestHandlerInterface
    {
        return new CallableRequestHandler(function (RequestInterface $request) use ($stack, $index) {
            $middleware = isset($this->stack[$index]) ? $stack[$index] : null;
            return $middleware ?
                $middleware->process($request, $this->resolve($stack, $index + 1)) :
                (new CalgamoTerminateHandler($this->response))->handle($request);
        });
    }
627526
public boolean isInvite() {
    if (message == null) {
      return false;
    }

    return (((Request) message).getMethod().equals(Request.INVITE));
  }
849682
def should_submit(stack):
    
    if stack.enabled:
        return True

    logger.debug("Stack %s is not enabled.  Skipping.", stack.name)
    return False
915516
protected function seedHandlerStack()
    {
        if (!is_null($this->handlers)) {
            throw new \RuntimeException('Handler stacks can only be seeded once.');
        }
        $this->stacks = [];
        $base = new BaseHandler();
        $this->handlers = [$base];

        $this->stacks['delete'] = new \SplStack();
        $this->stacks['clean'] = new \SplStack();
        $this->stacks['create'] = new \SplStack();
        $this->stacks['read'] = new \SplStack();
        $this->stacks['write'] = new \SplStack();

        foreach($this->stacks as $id => $stack) {
            $stack->setIteratorMode(\SplDoublyLinkedList::IT_MODE_LIFO | \SplDoublyLinkedList::IT_MODE_KEEP);
            $stack[] = array( $base, $id );
        }
    }
532877
public function handle(Envelope $envelope, StackInterface $stack): Envelope
    {
        $handler = null;
        $message = $envelope->getMessage();

        $context = [
            'message' => $message,
            'class' => \get_class($message),
        ];

        $exceptions = [];
        foreach ($this->handlersLocator->getHandlers($envelope) as $handlerDescriptor) {
            if ($this->messageHasAlreadyBeenHandled($envelope, $handlerDescriptor)) {
                continue;
            }

            try {
                $handler = $handlerDescriptor->getHandler();
                $handledStamp = HandledStamp::fromDescriptor($handlerDescriptor, $handler($message));
                $envelope = $envelope->with($handledStamp);
                $this->logger->info('Message "{class}" handled by "{handler}"', $context + ['handler' => $handledStamp->getHandlerName()]);
            } catch (\Throwable $e) {
                $exceptions[] = $e;
            }
        }

        if (null === $handler) {
            if (!$this->allowNoHandlers) {
                throw new NoHandlerForMessageException(sprintf('No handler for message "%s".', $context['class']));
            }

            $this->logger->info('No handler for message "{class}"', $context);
        }

        if (\count($exceptions)) {
            throw new HandlerFailedException($envelope, $exceptions);
        }

        return $stack->next()->handle($envelope, $stack);
    }
1251600
public function stackExists(Image $client, $stackName, $organizationName = '')
    {
        try {
            $stack = $client->getStack($stackName, $organizationName);

            return $stack->getName() == $stackName;
        } catch (ClientException $e) {
            if (404 === $e->getCode()) {
                return false;
            }

            throw $e;
        }
    }
208043
@Override
  boolean push(TraceMethod traceMethod) {
    boolean success;
    TracingContext currentTracingContext = getCurrentTracingContext();
    if (currentTracingContext != null && !currentTracingContext.isCorrupted()) {
      if (currentTracingContext.getMethodStack().size() >= STACK_SIZE) {
        currentTracingContext.setCorrupted(true);
        throw new ThreadMap.RuntimeException("Stacksize is exceeded.");
      }
      else {
        currentTracingContext.getMethodStack().push(traceMethod);
        success = true;
      }
    }
    else
      success = false;
    
    return success;
  }