Restores previous position if OutOfBounds error occurs.

@param callable $moveAction

@return mixed
509070
private function safeMove(callable $moveAction)
    {
        $oldPosition = $this->position;

        try {
            return $moveAction();
        } catch (OutOfBoundsException $e) {
            $this->position = $oldPosition;

            throw $e;
        }
    }
594060
private function handleMoveCopy(MoveEvent $event)
    {
        $document = $event->getDocument();

        if (!$document instanceof AutoNameBehavior) {
            return;
        }

        $destId = $event->getDestId();
        $node = $this->registry->getNodeForDocument($document);
        $destNode = $this->nodeManager->find($destId);
        $nodeName = $this->resolver->resolveName($destNode, $node->getName());

        $event->setDestName($nodeName);
    }
171410
public function updateMovedDocument(MoveEvent $event)
    {
        $document = $event->getDocument();
        if (!$document instanceof ResourceSegmentBehavior) {
            return;
        }

        $webspaceKey = $this->documentInspector->getWebspace($event->getDocument());
        if (!$webspaceKey) {
            return;
        }

        $resourceLocatorStrategy = $this->resourceLocatorStrategyPool->getStrategyByWebspaceKey($webspaceKey);
        if (ResourceLocatorStrategyInterface::INPUT_TYPE_LEAF !== $resourceLocatorStrategy->getInputType()) {
            return;
        }

        $this->updateRoute($document, true);
    }
559083
function transaction( $action )
    {
        switch ( $action )
        {
        case 'start':
            // store all the data away into the checkpoint variable
            $data = get_object_vars( $this );
            $this->checkpoint = $data;
            unset( $data );
            break;
        case 'commit':
            if ( is_array( $this->checkpoint ) && isset( $this->checkpoint['checkpoint'] ) )
            {
                $tmp = $this->checkpoint['checkpoint'];
                $this->checkpoint = $tmp;
                unset( $tmp );
            }
            else
            {
                $this->checkpoint = '';
            }
            break;
        case 'rewind':
            // do not destroy the current checkpoint, but move us back to the state then, so that we can try again
            if ( is_array( $this->checkpoint ) )
            {
                // can only abort if were inside a checkpoint
                $tmp = $this->checkpoint;
                foreach ( $tmp as $k => $v )
                {
                    if ( $k != 'checkpoint' )
                    {
                        $this->$k = $v;
                    }
                }
                unset($tmp);
            }
            break;
        case 'abort':
            if ( is_array( $this->checkpoint ) )
            {
                // can only abort if were inside a checkpoint
                $tmp = $this->checkpoint;
                foreach ( $tmp as $k => $v )
                {
                    $this->$k = $v;
                }
                unset($tmp);
            }
            break;
        }

    }
507845
public function seek($position)
    {
        if (! isset($this->string[$position])) {
            throw new OutOfBoundsException("invalid seek position ($position)");
        }
        $this->position = $position;
        return $this;
    }
374465
protected function _actionIsEnabled($action)
    {
        $actions = $this->type['actions'];

        if (array_key_exists($action, $actions)) {
            return $actions[$action];
        }
        return true;
    }
398592
public function beforeNodeMove(NodeInterface $movedNode, NodeInterface $referenceNode, $moveOperation)
    {
        if (!$this->eventEmittingService->isEnabled()) {
            return;
        }

        $this->currentlyMoving += 1;

        /* @var $nodeEvent NodeEvent */
        $nodeEvent = $this->eventEmittingService->emit(self::NODE_MOVE, [
            'referenceNode' => $referenceNode->getContextPath(),
            'moveOperation' => $moveOperation
        ], NodeEvent::class);
        $nodeEvent->setNode($movedNode);
        $this->eventEmittingService->pushContext();
    }
105141
protected function handleAction($request, $action)
    {
        foreach ($request->latestParams() as $k => $v) {
            if ($v || !isset($this->urlParams[$k])) {
                $this->urlParams[$k] = $v;
            }
        }

        $this->action = $action;
        $this->requestParams = $request->requestVars();

        if ($this->hasMethod($action)) {
            $result = parent::handleAction($request, $action);

            // If the action returns an array, customise with it before rendering the template.
            if (is_array($result)) {
                return $this->getViewer($action)->process($this->customise($result));
            } else {
                return $result;
            }
        }

        // Fall back to index action with before/after handlers
        $beforeResult = $this->extend('beforeCallActionHandler', $request, $action);
        if ($beforeResult) {
            return reset($beforeResult);
        }

        $result = $this->getViewer($action)->process($this);

        $afterResult = $this->extend('afterCallActionHandler', $request, $action, $result);
        if ($afterResult) {
            return reset($afterResult);
        }

        return $result;
    }
491559
protected function action($action)
    {
        $action = in_array($action, $this->actions) ? $action : null;
        $action = array_key_exists($action, $this->aliases) ? $this->aliases[$action] : $action;

        return $action;
    }
553379
public function referenceGetAction($demAction)
    {
        $result = MageType::REF_ACTION_NO_ACTION;
        if ($demAction == DemType::REF_ACTION_RESTRICT) {
            $result = MageType::REF_ACTION_RESTRICT;
        } else {
            if ($demAction == DemType::REF_ACTION_CASCADE) {
                $result = MageType::REF_ACTION_CASCADE;
            }
        }
        return $result;
    }
126271
public function action($action)
    {
        $a = func_get_args();
        $controllerPath = $this->controller->getControllerActionPath();
        array_unshift($a, $controllerPath);
        $ret = call_user_func_array([$this, 'url'], $a);

        return $ret;
    }
760121
private static function str2closure($controllerAction)
    {
        list($controller, $action) = explode('@', $controllerAction);
        return function($request) use ($controller, $action) {
            $c = new $controller;
            return call_user_func([$c, $action], $request);
        };
    }
1352255
public function placeAt(Sortable $movedNode, Sortable $newParent, $position)
    {
        // 1. movedNode.parentId = newDescendant.parentId, movedNode.position = MAX(newDescendant.position,1)
        // 2. removeFromSort(movedNode) like delete without delete
        // 2. UPDATE SET position = position+1 WHERE parentId = newAncestor.parentId
        //    AND position >= movedNode.position
        // 3. movedNode.save()

        $targetParentId = $newParent->getId();
        $targetPosition = $position;
        $oldParentId = $movedNode->getParentId();
        $oldPosition = $movedNode->getPosition();

        // Nothing to do
        if ($targetParentId == $oldParentId &&
            $targetPosition == $oldPosition &&
            $movedNode->exists) {
            return $this;
        }

        $movedNode[$this->getParentIdName()] = $targetParentId;
        $movedNode[$this->getPositionName()] = $targetPosition;

        // Remove node from old parent
        $this->decrementOrderAfter($oldParentId, $oldPosition);

        // Create space for new position
        $this->incrementOrderAfter($targetParentId, $targetPosition-1);

        $movedNode->save();

        return $this;

    }
721935
public static function move($from, $to)
    {
        return self::copy($from, $to) && self::delete($from);
    }
1242067
public function callAction($action, $defaultAction = 'request') {
		if (method_exists($this, $action)) return $this->{$action}();
		else return $this->{$defaultAction}();
	}
1066219
public function kick($action, $max)
    {
        $this->pheanstalk->useTube($action);

        $kicked = $this->pheanstalk->kick($max);

        $this->logger->debug(
            sprintf('Kicked %d "%s" jobs back onto the ready queue', $kicked, $action)
        );

        return $kicked;
    }
37328
final protected function shiftLeftFromPos($position)
    {
        $cnt = parent::count();
        if ($position < 1 || $position >= $cnt) {
            throw new \OutOfBoundsException('position to shift from must be in range 1..Length-1');
        }
        for ($i = $position; $i < $cnt; $i++) {
            $this->items[$i - 1] = $this->items[$i];
        }
    }