Jarves\Storage\Propel::move PHP Method

move() public method

{@inheritDoc}
public move ( $pk, $targetPk, $position = 'first', $targetObjectKey = null )
    public function move($pk, $targetPk, $position = 'first', $targetObjectKey = null)
    {
        $query = $this->getQueryClass();
        $item = $query->findPK($this->getPropelPk($pk));
        $method = 'moveToFirstChildOf';
        if ($position == 'up' || $position == 'before' || $position == 'prev') {
            $method = 'moveToPrevSiblingOf';
        }
        if ($position == 'down' || $position == 'below' || $position == 'next') {
            $method = 'moveToNextSiblingOf';
        }
        if (!$targetPk) {
            //we need a target
            return null;
        } else {
            if ($targetObjectKey && $this->getObjectKey() != $targetObjectKey) {
                if (!$this->definition['nestedRootAsObject']) {
                    throw new \InvalidArgumentException('This object has no different object as root.');
                }
                $scopeId = $item->getScopeValue();
                $method = 'moveToFirstChildOf';
                $target = $query->findRoot($scopeId);
            } else {
                $target = $query->findPK($this->getPropelPk($targetPk));
            }
            if (!$target) {
                return false;
            }
        }
        if ($item == $target) {
            return false;
        }
        if ($target) {
            return $item->{$method}($target) ? true : false;
        } else {
            throw new \Exception('Can not find the appropriate target.');
        }
    }