Habari\FormContainer::move PHP Метод

move() публичный Метод

Moves a control to target's position to which we add $int if specified That integer is useful to move before or move after the target
public move ( FormControl $source, FormControl $target, integer $offset )
$source FormControl FormControl object to move
$target FormControl FormControl object acting as destination
$offset integer Integer added to $target's position (index)
    function move(FormControl $source, FormControl $target, $offset = 0)
    {
        // Remove the source control from its container's list of controls
        $controls = array();
        $source_name = false;
        foreach ($source->container->controls as $name => $ctrl) {
            if ($ctrl === $source) {
                $source_name = $name;
                continue;
            }
            $controls[$name] = $ctrl;
        }
        if ($source_name) {
            $source->container->controls = $controls;
            // Insert the source control into the destination control's container's list of controls in the correct location
            $target_index = array_search($target, array_values($target->container->controls), true);
            $left_slice = array_slice($target->container->controls, 0, $target_index + $offset, true);
            $right_slice = array_slice($target->container->controls, $target_index + $offset, count($target->container->controls), true);
            $target->container->controls = $left_slice + array($source_name => $source) + $right_slice;
        }
    }