Updates orders

@param string $json JSON string
@param \Krystal\Tree\AdjacencyList\ChildrenOrderSaverMapperInterface $mapper
@return boolean
8700
public function update($json, ChildrenOrderSaverMapperInterface $mapper)
    {
        $array = $this->parse($json);

        foreach ($array as $range => $value) {
            if (is_array($value)) {
                $mapper->save($value[RelationBuilder::TREE_PARAM_ID], $value[RelationBuilder::TREE_PARAM_PARENT_ID], $range);
            }
        }

        return true;
    }
538999
final public function update(array $keys = null)
    {
        $pre = $this->preUpdate($keys);
        if ($pre === false) {
            $this->logger->error(sprintf(
                'Can not update object "%s:%s"; cancelled by %s::preUpdate()',
                $this->objType(),
                $this->id(),
                get_called_class()
            ));
            return false;
        }

        $ret = $this->source()->updateItem($this, $keys);
        if ($ret === false) {
            $this->logger->error(sprintf(
                'Can not update object "%s:%s"; repository failed for %s',
                $this->objType(),
                $this->id(),
                get_called_class()
            ));
            return false;
        }

        $post = $this->postUpdate($keys);
        if ($post === false) {
            $this->logger->warning(sprintf(
                'Updated object "%s:%s" but %s::postUpdate() failed',
                $this->objType(),
                $this->id(),
                get_called_class()
            ));
            return false;
        }

        return true;
    }
826232
public function setListMapper(ListMapper $mapper)
	{
		$this->listMapper = $mapper;
		$mapper->setAdmin($this);
		return $this;
	}
60981
public function reset($mapper = true) {
		if ($mapper)
			$this->mapper->reset();
		$this->fieldsCache=[];
		$this->saveCsd=[];
		$this->countFields=[];
		$this->preBinds=[];
		$this->grp_stack=null;
		// set default values
		if (($this->dbsType == 'jig' || $this->dbsType == 'mongo')
			&& !empty($this->fieldConf))
			foreach($this->fieldConf as $field_key => $field_conf)
				if (array_key_exists('default',$field_conf)) {
					$val = ($field_conf['default'] === \DB\SQL\Schema::DF_CURRENT_TIMESTAMP)
						? date('Y-m-d H:i:s') : $field_conf['default'];
					$this->set($field_key, $val);
				}
	}
491152
public function insert($table, $tables, $json): bool
    {
        $this->json = $json;

        $this->setTargetTable($table, $tables);

        if (!$this->needGenerate()) {
            return false;
        }

        $filePath = $this->getTargetFilePath();

        $json = $this->parseJson($filePath);

        $exist = $this->checkItAlreadyExists($json);
        if ($exist) {
            return false;
        }

        $json = $this->insertItem($json);

        return $this->outputJson($json, $filePath);
    }
284865
private function addDefaultSortOrders($orders, MappingInterface $mapping)
    {
        $defaultOrders = [
            SortOrderInterface::DEFAULT_SORT_FIELD => SortOrderInterface::SORT_DESC,
            $mapping->getIdField()->getName()      => SortOrderInterface::SORT_DESC,
        ];

        if (count($orders) > 0) {
            $firstOrder = current($orders);
            if ($firstOrder['direction'] == SortOrderInterface::SORT_DESC) {
                $defaultOrders[SortOrderInterface::DEFAULT_SORT_FIELD] = SortOrderInterface::SORT_ASC;
                $defaultOrders[$mapping->getIdField()->getName()]      = SortOrderInterface::SORT_ASC;
            }
        }

        foreach ($defaultOrders as $currentOrder => $direction) {
            if (!in_array($currentOrder, array_keys($orders))) {
                $orders[$currentOrder] = ['direction' => $direction];
            }
        }

        return $orders;
    }
142152
public function setShardKey(array $keys, array $options = array())
    {
        if ($this->inheritanceType == self::INHERITANCE_TYPE_SINGLE_COLLECTION && !is_null($this->shardKey)) {
            throw MappingException::shardKeyInSingleCollInheritanceSubclass($this->getName());
        }

        if ($this->isEmbeddedDocument) {
            throw MappingException::embeddedDocumentCantHaveShardKey($this->getName());
        }

        $this->shardKey = array(
            'keys' => array_map(function($value) {
                if ($value == 1 || $value == -1) {
                    return (int) $value;
                }
                if (is_string($value)) {
                    $lower = strtolower($value);
                    if ($lower === 'asc') {
                        return 1;
                    } elseif ($lower === 'desc') {
                        return -1;
                    }
                }
                return $value;
            }, $keys),
            'options' => $options
        );
    }
225813
public function updateCustomer($parameters = [])
    {
        $response = $this->client->put('customers/' . $parameters['customer_id'], [
            'json' => $parameters,
        ]);
        return json_decode($response->getBody())->customer;
    }
472480
public function set($key, $value)
    {
        if (! $value instanceof EntityMapperInterface) {
            throw new InvalidArgumentException(
                'Trying to add a non EntityMapper to MappersMap.'
            );
        }
        return parent::set($key, $value);
    }
98000
public function update($entityKey)
    {
        sharp_check_ability("update", $entityKey);

        $list = $this->getListInstance($entityKey);
        $list->buildListConfig();

        $list->reorderHandler()->reorder(
            request("instances")
        );

        return response()->json([
            "ok" => true
        ]);
    }
1197296
public function load(Map $map)
    {

        $this->changedRatings = [];
        $this->ratingsPerPlayer = [];
        MapratingTableMap::clearInstancePool();

        /** @var Maprating[] $ratings */
        $ratings = $this->mapratingQueryBuilder->getRatingsForMap($map);

        foreach ($ratings as $rating) {
            $this->ratingsPerPlayer[$rating->getLogin()] = $rating;
        }

        $this->dispatcher->dispatch("expansion.mapratings.loaded", [$this->ratingsPerPlayer]);
    }
37359
public function doSerialize(
        JsonSerializationVisitor $visitor,
        ChildrenCollection $childrenCollection,
        array $type,
        Context $context
    ) {
        $array = $childrenCollection->toArray();

        return $context->accept($array);
    }
1087160
private function updateNavigationListOrder($id, $listOrder, $parentId = 0)
    {
        $row = Page::find($id);
        $row->parent_id = $parentId;
        //if ($row->url_parent_id != 0) {
            // update the url parent id as well
            $row->url_parent_id = $parentId;
        //}

        $row->updateUrl();
        $row[$this->orderProperty] = $listOrder;
        $row->save();

        return $row;
    }
504370
public function respond($mapper, $data)
    {
        $arguments = [];
        // if data is instance of Paginator then get the values of the total and the page from the paginator,
        // and add them to the arguments array (total, page)
        if ($this->isPaginatorInstance($data)) {
            $arguments[0] = $data->total();
            $arguments[1] = $data->currentPage();
            $arguments[2] = $data->perPage();
        }
        // skip the first 2 arguments and save the rest to the 'arguments array':
        // > in case data is instance of Paginator then this will append all the arguments to the 'arguments array'
        // starting by the third arguments which should be the 'status'.
        // > in case data is is not instance of Paginator (means total and page and per_page are added manually as
        // arguments) then this will add all the arguments to the 'arguments array' starting by the third arguments
        // which should be the 'page'.
        foreach (array_slice(func_get_args(), 2) as $arg) {
            $arguments[count($arguments)] = $arg;
        }
        $result[] = $this->data($mapper, $data);

        return call_user_func_array([$this->response_handler, 'respond'], array_merge($result, $arguments));
    }
1155647
public function from(IObjectMapper $mapper)
    {
        $this->mapper     = $mapper;
        $this->definition = $mapper->getDefinition();
        $this->relations  = $this->definition->getPropertyRelationMap();

        if ($mapper instanceof IEntityMapper) {
            foreach ($mapper->getPrimaryTable()->getColumns() as $column) {
                $this->readDefinition->addColumn($column);
            }
        }

        $this->validProperties = $this->definition->getPropertyColumnMap() + $this->relations;
    }
478005
private function createList(Mapper $mapper, array $items)
    {
        $result = [];
        foreach ($items as $item) {
            $result[] = $mapper->createObject($item);
        }

        return $result;
    }
1153600
public function initializeRelations(IObjectMapper $mapper)
    {
        if ($this->hasInitializedRelations) {
            return;
        }

        if ($mapper instanceof IEmbeddedObjectMapper) {
            $this->entityTable = $mapper->getTableWhichThisIsEmbeddedWithin();
        } else {
            $this->entityTable = $this->table;
        }

        $relationMappings = call_user_func($this->relationMappingsFactory, $this->entityTable, $mapper);

        foreach ($relationMappings as $relationMapping) {
            if ($relationMapping instanceof ToOneRelationMapping) {
                $this->toOneRelations[] = $relationMapping;
            } elseif ($relationMapping instanceof ToManyRelationMapping) {
                $this->toManyRelations[] = $relationMapping;
            } else {
                throw InvalidArgumentException::format('Unknown relation mapping type: %s', Debug::getType($relationMapping));
            }
        }

        $this->table = $this->table->withForeignKeys(array_merge(
            $this->table->getForeignKeys(),
            call_user_func($this->foreignKeysFactory, $this->table)
        ));

        foreach ($this->subClassMappings as $subClassMapping) {
            $subClassMapping->initializeRelations($mapper);
        }

        $embeddedForeignKeys = [];

        foreach ($this->findEmbeddedObjectRelations($this->toOneRelations) as $relation) {
            foreach ($relation->getMapper()->getDefinition()->getTable()->getForeignKeys() as $foreignKey) {
                $embeddedForeignKeys[] = $foreignKey;
            }
        }

        foreach ($this->findEmbeddedSubclassMappings($this->subClassMappings) as $subClassMapping) {
            foreach ($subClassMapping->getDefinition()->getTable()->getForeignKeys() as $foreignKey) {
                $embeddedForeignKeys[] = $foreignKey;
            }
        }

        $this->table = $this->table->withForeignKeys(array_merge(
            $this->table->getForeignKeys(),
            $embeddedForeignKeys
        ));

        $this->hasInitializedRelations = true;
    }