Moves the row up.

@param Model\RowInterface $row

@return Model\RowInterface the sibling row that has been swapped.
@throws InvalidOperationException
509944
public function moveUp(Model\RowInterface $row)
    {
        $sibling = $this->editor->getRepository()->findSiblingRow($row, false);
        if (null === $sibling) {
            throw new InvalidOperationException(
                "The row can't be moved up as no sibling row has been found."
            );
        }

        $row->setPosition($row->getPosition() - 1);
        $sibling->setPosition($sibling->getPosition() + 1);

        $this->sortChildrenByPosition($row->getContainer(), 'rows');

        return $sibling;
    }
362533
public function addRow(GridRow $row)
    {
        if (!$this->rows->contains($row)) {
            $this->rows->add($row);
            $row->setQuestion($this);
        }
    }
1133955
public function loadFromRow($row)
    {
        // Loop over the columns, sanitise and store it into the new properties of this object.
        foreach ($row as $column => &$value) {
            // Only save columns beginning with a normal letter.
            if (preg_match('/^[a-z]/i', $column)) {
                $this->$column = & $value;
            }
        }
        $this->postConstruct();
        if (DatabaseLayer::getInstance()->useCache() && $this->_caching_enabled) {
            $cache = DatabaseLayer::getInstance()->getCache();
            $cache->save($this->getCacheIdentifier(), serialize($this));
        }
        return $this;
    }
1233912
public function reset( $row = null ) {

		/**
		 * Runs directly before the Pods object is reset by reset()
		 *
		 * @since unknown
		 *
		 * @param int|string|null The ID of the row being reset to or null if being reset to the beginning.
		 * @param object|Pods $this Current Pods object.
		 */
		do_action( 'pods_pods_reset', $row, $this );

		$this->data->reset( $row );

		return $this;
	}
1228226
public function updateNodeSet(RowInterface $row, $propertyData)
    {
        $node = $row->getNode($propertyData['selector']);
        $value = $propertyData['value'];

        if ($value instanceof FunctionOperand) {
            $value = $propertyData['value'];
            $value = $value->execute($this->functionMapSet, $row);
        }

        $node->setProperty($propertyData['name'], $value);
    }
947320
private function resolveHasChildren(Row $row)
    {
        $queryBuilder = new QueryBuilder($this->qomFactory);

        $queryBuilder
            ->select('node', 'jcr:uuid', 'uuid')
            ->from($this->qomFactory->selector('node', 'nt:unstructured'))
            ->where($this->qomFactory->childNode('node', $row->getPath()))
            ->setMaxResults(1);

        $result = $queryBuilder->execute();

        return count(iterator_to_array($result->getRows())) > 0;
    }
1256825
public function delete(KDatabaseRowInterface $row)
    {
        // Create query object.
        $query = $this->getObject('lib:database.query.delete')
            ->table($this->getBase());

        //Create commandchain context
        $context = $this->getContext();
        $context->table     = $this->getBase();
        $context->data      = $row;
        $context->query     = $query;
        $context->affected  = false;

        if ($this->invokeCommand('before.delete', $context) !== false)
        {
            foreach ($this->getPrimaryKey() as $key => $column)
            {
                $context->query->where($column->name . ' = :' . $column->name)
                    ->bind(array($column->name => $context->data->$key));
            }

            // Execute the delete query.
            $context->affected = $this->getAdapter()->delete($context->query);

            // Set the query in the context.
            if ($context->affected !== false) {
                $context->data->setStatus($context->affected ? KDatabase::STATUS_DELETED : KDatabase::STATUS_FAILED);
            }

            $this->invokeCommand('after.delete', $context);
        }

        return $context->affected;
    }
810409
public function row(int $row): bool
    {
        $this->resultExists();
        return $this->result->row($row);
    }
1036956
private function getJobFromRow(array $row)
    {
        $type = $row['type'];

        /** @var Job $job */
        $job = new $type($this->jsonDecode($row['data']));
        $job->setChannel($row['channel']);
        $job->setBatchId($row['batch_id']);
        $job->setQueue($this, (integer) $row['id']);

        return $job;
    }
838800
public function fixBlocksPositions(Model\RowInterface $row)
    {
        $this->sortChildrenByPosition($row, 'blocks');

        /** @var Model\BlockInterface[] $blocks */
        $blocks = $row->getBlocks();

        $position = 0;
        foreach ($blocks as $block) {
            $block->setPosition($position);
            $position++;
        }

        return $this;
    }
182291
public function update(KDatabaseRowInterface $row)
    {
        // Create query object.
        $query = $this->getObject('lib:database.query.update')
            ->table($this->getBase());

        // Create commandchain context.
        $context = $this->getContext();
        $context->table     = $this->getBase();
        $context->data      = $row;
        $context->query     = $query;
        $context->affected  = false;

        if ($this->invokeCommand('before.update', $context) !== false)
        {
            foreach ($this->getPrimaryKey() as $key => $column)
            {
                $context->query->where($column->name . ' = :' . $key)
                    ->bind(array($key => $context->data->$key));
            }

            // Filter the data and remove unwanted columns.
            $data = $this->filter($context->data->getProperties(true));

            foreach ($this->mapColumns($data) as $key => $value) {
                $query->values($key . ' = :_' . $key)->bind(array('_' . $key => $value));
            }

            // Execute the update query.
            $context->affected = $this->getAdapter()->update($context->query);

            // Set the status and data before calling the command chain
            if ($context->affected !== false)
            {
                if ($context->affected) {
                    $context->data->setProperties($this->mapColumns($data, true), true)->setStatus(KDatabase::STATUS_UPDATED);
                } else {
                    $context->data->setStatus(KDatabase::STATUS_FAILED);
                }
            }

            $this->invokeCommand('after.update', $context);
        }

        return $context->affected;
    }
479479
public function process(array $row)
    {
        foreach ($row as &$item) {
            if (is_object($item)) {
                if (method_exists($item, '__toString')) {
                    $item = $item->__toString();
                } else {
                    throw new InvalidArgumentException("Supplied object does not implement __toString");
                }
            }
        }

        return $row;
    }
363073
private function migrateRow(array $row): void
    {
        $data = ['tstamp' => time()];

        foreach (self::SIZES as $size) {
            $size       .= 'Size';
            $data[$size] = $this->migrateSize($row[$size]);
        }

        $this->connection->update('tl_bs_grid', $data, ['id' => $row['id']]);
    }
298177
protected function setCurrentRow($row)
    {
        if (!in_array($this->return_mode, [ConnectionInterface::RETURN_OBJECT_BY_CLASS, ConnectionInterface::RETURN_OBJECT_BY_FIELD], true)) {
            $this->current_row = $row;
            $this->getValueCaster()->castRowValues($this->current_row);

            return;
        }

        $class_name = $this->return_mode === ConnectionInterface::RETURN_OBJECT_BY_CLASS
            ? $this->return_class_or_field
            : $row[$this->return_class_or_field];

        if (empty($this->constructor_arguments)) {
            $this->current_row = new $class_name();
        } else {
            $this->current_row = (new ReflectionClass($class_name))->newInstanceArgs($this->constructor_arguments);
        }

        if ($this->current_row instanceof ContainerAccessInterface && $this->container) {
            $this->current_row->setContainer($this->container);
        }

        $this->current_row->loadFromRow($row);
    }
103735
public function setFromArray(array $row = [])
    {
        parent::setFromArray($row);
        try {
            $data = $this->data ? json_decode($this->data, true) : [];
        } catch (\Exception $e) {
            $data = [];
        }
        $this->data = (new DataObject)->setParams($data);
        return $this;
    }
868730
protected function initFromRow($row)
    {
        if ($row === null) {
            throw new SwatDBException(
                'Attempting to initialize dataobject with a null row.'
            );
        }

        $property_array = array_merge(
            $this->getPublicProperties(),
            $this->getSerializableProtectedProperties()
        );

        if (is_object($row)) {
            $row = get_object_vars($row);
        }

        foreach ($property_array as $name => $value) {
            // Use array_key_exists() instead of isset(), because isset() will
            // return false when the value is null. Null values on properties
            // should not be ignored - otherwise calling initFromRow() on an
            // existing dataobject can leave out of date values on properties
            // when those values were updated to null.
            if (array_key_exists($name, $row)) {
                if (
                    in_array($name, $this->date_properties) &&
                    $row[$name] !== null
                ) {
                    $this->$name = new SwatDate($row[$name]);
                } else {
                    $this->$name = $row[$name];
                }
            }
        }

        foreach ($this->internal_properties as $name => $value) {
            if (isset($row[$name])) {
                $this->internal_properties[$name] = $row[$name];
            }
        }

        $this->loaded_from_database = true;
    }
701222
public function with($row = null)
    {
        is_array($row) && $row = new Fluent($row);

        if (!is_null($row)) {
            $this->row = $row;
        }

        return $this->row;
    }