RedBean update method
Automates position assigning

@return void
960286
protected function sortableUpdate()
    {
        $table = $this->getTableName();

        if (!$this->position || ($this->position && count($this->app['redbean']->find($table, 'position = ? AND id != ?', [$this->position, $this->id])))) {
            $position = $this->app['redbean']->getCell('SELECT position FROM '.$table.' ORDER BY position DESC LIMIT 1');
            $this->position = $position + 1;
        }
    }
1246210
private function incrementPositions(array $conditions, ?int $startPosition = null, ?int $endPosition = null): void
    {
        $columnName = $conditions['column'];

        $query = $this->connection->createQueryBuilder();

        $query
            ->update($conditions['table'])
            ->set($columnName, $columnName . ' + 1');

        if ($startPosition !== null) {
            $query->andWhere($query->expr()->gte($columnName, ':start_position'));
            $query->setParameter('start_position', $startPosition, Type::INTEGER);
        }

        if ($endPosition !== null) {
            $query->andWhere($query->expr()->lte($columnName, ':end_position'));
            $query->setParameter('end_position', $endPosition, Type::INTEGER);
        }

        $this->applyConditions($query, $conditions['conditions']);

        $query->execute();
    }
259363
private function updateProperties()
    {
        $sections = Eresus_Kernel::app()->getLegacyKernel()->sections;
        $id = arg('section', 'int');
        $item = $sections->get($id);

        $item['title'] = arg('title', 'dbsafe');
        $item['created'] = arg('created', 'dbsafe');
        $item['active'] = arg('active', 'int');
        $item['content'] = arg('content', 'dbsafe');

        $sections->update($item);
        HTTP::redirect(arg('submitURL'));
    }
65322
private function updateUriQuery(): void
    {
        $sort = [];
        foreach ($this->order as $field => $direction) {
            if ($direction === self::ORDER_ASC) {
                $sort[] = $field;
            } elseif ($direction === self::ORDER_DESC) {
                $sort[] = '-' . $field;
            }
        }

        $fields = [];
        foreach ($this->fields as $type => $fields) {
            $fields[$type] = implode(',', $fields);
        }

        $query = [
            'sort' => implode(',', $sort),
            'pagination' => $this->pagination,
            'filter' => $this->filter,
            'include' => implode(',', $this->includes),
            'fields' => $fields
        ];

        $this->uri = $this->uri()->withQuery(http_build_query($query));
    }
124289
protected function genericUpdatePosition(ModelCriteria $query, UpdatePositionEvent $event, EventDispatcherInterface $dispatcher = null)
    {
        if (null !== $object = $query->findPk($event->getObjectId())) {
            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();
            }
        }
    }
806727
protected void repositionButtons() {

        for (Map.Entry<String, CmsDirectEditButtons> entry : m_directEditButtons.entrySet()) {
            CmsDirectEditButtons buttons = entry.getValue();
            Element tag = buttons.getMarkerTag();
            CmsPositionBean newPos = CmsDomUtil.getEditablePosition(tag);
            m_positions.put(tag.getId(), newPos);
        }
        CmsEditablePositionCalculator posCalc = new CmsEditablePositionCalculator(m_positions);
        m_buttonPositions = posCalc.calculatePositions();
        for (CmsDirectEditButtons buttons : m_directEditButtons.values()) {
            String id = buttons.getMarkerTag().getId();
            buttons.setPosition(
                m_positions.get(id),
                m_buttonPositions.get(id),
                buttons.getMarkerTag().getParentElement());
        }

    }
629673
function( cb ){
              if( ! self.positionField ){
                cb( null );
              } else {

                // If repositioning is required, do it
                if( self.positionField ){
                  var where, beforeId;
                  if( ! options.position ){
                    where = 'end';
                  } else {
                    where = options.position.where;
                    beforeId = options.position.beforeId;
                  }
                  self.reposition( recordWithLookups, where, beforeId, cb );
                }
              }
            }
412956
public function actionUpdate() {
		
		try {
			\App::$domain->rbac->role->update();
		} catch(NotAuthenticatedException $e) {
			\App::$domain->account->auth->breakSession();
			echo 'NotAuthenticatedException';
			return;
		} catch(UnauthorizedHttpException $e) {
			\App::$domain->account->auth->breakSession();
			echo 'UnauthorizedHttpException';
			return;
		}
		echo 'success';
	}
460251
public function actionUpdate()
	{
		$post=$this->loadPost();
		if(Yii::app()->request->isPostRequest)
		{
			if(isset($_POST['Post']))
				$post->setAttributes($_POST['Post']);
			if($post->save())
				$this->redirect(array('show','id'=>$post->id));
		}
		$this->render('update',array('post'=>$post));
	}
677533
public function updatePositionAction()
    {
        // Check current user authorization
        if (null !== $response = $this->checkAuth($this->resourceCode, $this->getModuleCode(), AccessManager::UPDATE)) {
            return $response;
        }

        try {
            $mode = $this->getRequest()->get('mode', null);

            if ($mode == 'up') {
                $mode = UpdatePositionEvent::POSITION_UP;
            } elseif ($mode == 'down') {
                $mode = UpdatePositionEvent::POSITION_DOWN;
            } else {
                $mode = UpdatePositionEvent::POSITION_ABSOLUTE;
            }

            $position = $this->getRequest()->get('position', null);

            $event = $this->createUpdatePositionEvent($mode, $position);

            $this->dispatch($this->changePositionEventIdentifier, $event);
        } catch (\Exception $ex) {
            // Any error
            return $this->errorPage($ex);
        }

        $response = $this->performAdditionalUpdatePositionAction($event);

        if ($response == null) {
            return $this->redirectToListTemplate();
        } else {
            return $response;
        }
    }
48907
public function changePositionAction()
    {
        $request = $this->getRequest();
        if ($request->isXmlHttpRequest())
        {
            $em = $this->getDoctrine()->getManager();
            $pageRepository = $this->getDoctrine()->getRepository('FulgurioLightCMSBundle:Page');
            $page = $this->getPage($request->request->get('pageId'));
            $parentId = $request->request->get('parentId');
            $position = $request->request->get('position');
            if ($parentId != $page->getParent()->getId())
            {
                $pageRepository->downPagesPosition($parentId, $position);
                $pageRepository->upPagesPosition($page->getParent(), $page->getPosition() + 1);
                $page->setParent($pageRepository->find($parentId));
                $models = $this->container->getParameter('fulgurio_light_cms.models');
                $formHandlerClassName = isset($models[$page->getModel()]['back']['handler']) ? $models[$page->getModel()]['back']['handler'] : '\Fulgurio\LightCMSBundle\Form\Handler\AdminPageHandler';
                $formHandler = new $formHandlerClassName();
                $formHandler->setDoctrine($this->getDoctrine());
                $formHandler->makeFullpath($page);
                $em->persist($page);
                $em->flush();
            }
            else
            {
                if ($position > $page->getPosition())
                {
                    $pageRepository->upPagesPosition($page->getParent(), $page->getPosition() + 1, $position - 1);
                    --$position;
                }
                else
                {
                    $pageRepository->downPagesPosition($page->getParent(), $position, $page->getPosition() - 1);
                }
            }
            $page->setPosition($position);
            $em->persist($page);
            $em->flush();
            $response = new Response(json_encode(array('code' => 42)));
            $response->headers->set('Content-Type', 'application/json');
            return $response;
        }
        throw new AccessDeniedException();
    }
904476
public function eventAfterUpdate()
    {
        $this->updateNavItemTimesamp();
        if (!empty($this->_olds)) {
            $oldPlaceholderVar = $this->_olds['placeholder_var'];
            $oldPrevId = (int) $this->_olds['prev_id'];
            if ($oldPlaceholderVar != $this->placeholder_var || $oldPrevId != $this->prev_id) {
                $this->reindex($this->nav_item_page_id, $oldPlaceholderVar, $oldPrevId);
            }
            $this->reindex($this->nav_item_page_id, $this->placeholder_var, $this->prev_id);
            Log::add(2, ['tableName' => 'cms_nav_item_page_block_item', 'action' => 'update', 'row' => $this->id, 'pageTitle' => $this->droppedPageTitle, 'blockName' => $this->block->getNameForLog()], 'cms_nav_item_page_block_item', $this->id);
        }
    }
188827
public function actionUpdate()
    {
        foreach ($this->repos as $repo) {
            $this->rebaseRepo($repo, $this->getFilesystemRepoPath($repo));
        }
        
        foreach ($this->getConfig(self::CONFIG_VAR_CUSTOMCLONES, []) as $repo => $path) {
            $this->rebaseRepo($repo, $path);
        }
    }
425843
public function updateRelated()
    {
        foreach ($this->related as $name => $value) {
            if ($value instanceof Manager) {
                continue;
            }

            /** @var \Mindy\Orm\Fields\RelatedField $field */
            $field = $this->getField($name);
            if ($field instanceof HasManyField) {
                continue;
            }
            if (empty($value)) {
                $field->getManager()->clean();
            } else {
                $field->setValue($value);
            }
        }
        $this->related = [];
    }
153482
public function setPosition($position)
	{
		if ( $position == $this->getPosition() ) { return; }

		$this->_values['pos'] = (int) $position;
		$this->setModified();
	}
812136
void updateCount() {
		if (this.hasChanged) {
			this.positionArray = ArrayUtils.toPrimitive(getPositionList()
					.toArray(new Long[0]));
			this.hasChanged = false;
		}
	}
149700
public function updateAction()
    {
        $request = $this->getRequest();
        if ($request->isPost()) {
            if ($this->getRequest()->getQuery('controller')) {
                $redirect = '?controller=' . $this->getRequest()->getQuery('controller')
                    . '&action=' . $this->getRequest()->getQuery('action')
                    . '&locale=' . $this->getRequest()->getQuery('locale');
            } else {
                $redirect = '';
            }

             $data = array_merge(
                 $request->getPost()->toArray(),
                 $request->getFiles()->toArray()
             );
   
            foreach ($data['translate'] as $locale => $values) {
                $return  = $this->getTranslateService()->writeFile($locale, $values);

                if ($return === false) {
                    $this->flashMessenger()->addMessage('The translate has not been updated');

                    return $this->redirect()->toUrl($this->url()->fromRoute('admin/playgroundtranslate') . $redirect);
                }

                $return = $this->getTranslateService()->activeTranslate($locale);

                if ($return === false) {
                    $this->flashMessenger()->addMessage('The translate has not been updated');

                    return $this->redirect()->toUrl($this->url()->fromRoute('admin/playgroundtranslate') . $redirect);
                }
                $this->flashMessenger()->addMessage('The translate has been updated');
            }
            sleep(2);

            return $this->redirect()->toUrl($this->url()->fromRoute('admin/playgroundtranslate') . $redirect);
        }

        return $this->redirect()->toUrl($this->url()->fromRoute('admin/playgroundtranslate') . $redirect);
    }