Easy static accessor for performing a move operation.

@param   NestedModel $model
@param   NestedModel|int $target
@param   string $position
@return NestedModel
350038
public static function to( $model, $target, $position )
	{
		$instance = new static( $model, $target, $position );

		return $instance->perform();
	}
1023506
public function moveAsPrevSiblingOf(Page $page, Page $target)
    {
        return $this->moveAsSiblingOf($page, $target, true);
    }
684864
private function synchronizeItems(OrderItemInterface $source, OrderItemInterface $target)
    {
        $accessor = PropertyAccess::createPropertyAccessor();
        foreach (array('designation', 'reference', 'price', 'weight', 'tax') as $property) {
            $value = $accessor->getValue($source, $property);
            if ($accessor->getValue($target, $property) != $value) {
                $accessor->setValue($target, $property, $value);
            }
        }
    }
253559
public function reposition($id, $position)
    {
        return $this->client->put(
            sprintf('buckets/%d/todolists/groups/%d/position.json', $this->bucket, $id),
            [
                'json' => [
                    'position' => $position,
                ],
            ]
        );
    }
643025
protected function determineModelReferenceStrategy(Model $model, $strategy = null)
    {
        if (null !== $strategy) {
            $strategy = $this->makeReferenceStrategyInstance($strategy);
        }

        if ( ! $strategy) {
            $strategy = $this->makeReferenceStrategy($model);
        }

        if ( ! $strategy) {
            $strategy = $this->getDefaultReferenceStrategyInstance();
        }

        return $strategy;
    }
845935
protected function genericUpdateDelegatePosition(ModelCriteria $query, UpdatePositionEvent $event, EventDispatcherInterface $dispatcher = null)
    {
        if (null !== $object = $query->findOne()) {
            if (!isset(class_uses($object)['Thelia\Model\Tools\PositionManagementTrait'])) {
                throw new \InvalidArgumentException("Your model does not implement the PositionManagementTrait trait");
            }

            //$object->setDispatcher($dispatcher !== null ? $dispatcher : $event->getDispatcher());

            $mode = $event->getMode();

            if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) {
                $object->changeAbsolutePosition($event->getPosition());
            } elseif ($mode == UpdatePositionEvent::POSITION_UP) {
                $object->movePositionUp();
            } elseif ($mode == UpdatePositionEvent::POSITION_DOWN) {
                $object->movePositionDown();
            }
        }
    }
538618
public function newLinkFrom(AbstractModel $model, array $linked)
    {
        foreach ($linked as & $foreign) {
            $foreign = $foreign->getRepo()->getIdentityMap()->get($foreign);
        }

        if ($this->linkClass) {
            $class = $this->linkClass;

            return new $class($model, $this, $linked);
        } else {
            return new LinkMany($model, $this, $linked);
        }
    }
1352133
public function getReferenceForModel(Model $model, $strategy = null, $source = null)
    {
        return $this->getReferenceValue($model, $strategy, $source);
    }
263303
public static function belongsTo($model, $options=null)
    {
        $cls = get_called_class();
        if (!array_key_exists($cls, self::$_belongs_to)) {
            self::$_belongs_to[$cls] = array();
        }
        self::$_belongs_to[$cls][$model] = $options ? $options : false;
    }
866723
public function push(Model $model)
    {
        $this->models[$model->getType()][$model->getId()] = $model;
        return $this;
    }
311853
public function setTarget($target)
    {
        if (!$target instanceof ModelInterface) {
            throw new Exception\InvalidArgumentException(sprintf(
                '"%s" works only with ModelInterface targets',
                __CLASS__
            ));
        }
        return parent::setTarget($target);
    }
184855
public function move(string $sourceInterface, string $sourceName, string $targetInterface, string $targetName)
    {
        $sourceIndex = $sourceInterface . '-' . $sourceName;
        if (! isset($this->container[$sourceIndex])) {
            throw $this->unbound($sourceIndex);
        }
        $targetIndex = $targetInterface . '-' . $targetName;
        $this->container[$targetIndex] = $this->container[$sourceIndex];
        unset($this->container[$sourceIndex]);
    }
427984
public function setPosition($position)
    {
        $this->position = max(min($position, $this->max), 0);
        return $this;
    }
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;

    }
235540
public function moveAfter($model)
    {
        if ( ! $model ) {
            $this->moveFirst();
            return;
        }
        if ( is_numeric($model) ) {
            $model = call_user_func("$this->ownerClassName::findOne", $model);
        }
        $parentId = $this->parentIdField ? $model->{$this->parentIdField} : 0;
        if ( $model->{$this->sortField} == $this->defaultSortVal ) {
            $this->reorder($parentId);
            $model->refresh();
        }
        $nextIdx = $this->getMinIdx($parentId, $model->{$this->sortField});
        if ( $nextIdx - $model->{$this->sortField} < 2 ) {
            $this->reorder($parentId);
            $model->refresh();
            $nextIdx = $this->getMinIdx($parentId, $model->{$this->sortField});
        }
        $newIdx = $model->{$this->sortField} + floor(($nextIdx - $model->{$this->sortField})/2);
        if ( $this->parentIdField ) {
            call_user_func("$this->ownerClassName::updateAll", [
                $this->sortField => $newIdx,
                $this->parentIdField => $parentId,
            ], [ $this->primaryKey => $this->owner->primaryKey ]);
        } else {
            call_user_func("$this->ownerClassName::updateAll",
                [ $this->sortField => $newIdx ],
                [ $this->primaryKey => $this->owner->primaryKey ]);
        }
        $this->invalidateTagDependency();
    }
1245057
public function setTargetModel($model)
    {
        if (is_string($model)) {
            $model = $this->modelFactory()->get($model);
        }

        if (!$model instanceof ModelInterface) {
            throw new InvalidArgumentException(
                sprintf(
                    'The model must be an instance of "%s"',
                    ModelInterface::class
                )
            );
        }

        $this->targetModel = $model;

        return $this;
    }
1118960
public function getOneToMany($target, $key = null, $target_key = null){
        $factory = $this->_db->factory($target);
        if(null === $key){
            $key = $this->getPK();
        }
        if(null === $target_key){
            $target_key = $key;
        }
        
        return $factory->findManyBy($target_key, $this->get($key));
    }