Update license

@param \Symfony\Component\HttpFoundation\Request $request

@return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
@throws \Exception
@throws \PropelException
171847
public function updateAction(Request $request)
        {

            /** @var License $oLicense */
            $oLicense = LicenseQuery::create()->findOne();

            if ($oLicense === null) {
                throw $this->createNotFoundException('Unable to find License entity.');
            }

            $editForm = $this->createEditForm($oLicense);
            $editForm->handleRequest($request);

            $aResult = array(
                "success" => false,
                "message" => ""
            );

            $sLico = SystemSettings::get("lico");

            $aHeaders = array(
                'Content-Type: application/json'
            );

            $sDomain = $this->_getSiteURL();

            $aRequest = array(
                'lico' => array(
                    'domain'  => $sDomain,
                    'license' => $oLicense->getSerial()
                ),
            );

            $sRequest = json_encode($aRequest);

            /*
             * Check license against license-server
             */
            $oRequest = curl_init($sLico . "/api/check/license");
            curl_setopt($oRequest, CURLOPT_HTTPHEADER, $aHeaders);
            curl_setopt($oRequest, CURLOPT_TIMEOUT, 120);
            curl_setopt($oRequest, CURLOPT_POST, 1);
            curl_setopt($oRequest, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($oRequest, CURLOPT_SSL_VERIFYHOST, false);
            curl_setopt($oRequest, CURLOPT_POSTFIELDS, $sRequest);
            curl_setopt($oRequest, CURLOPT_RETURNTRANSFER, true);
            $response    = curl_exec($oRequest);
            $iHttpStatus = curl_getinfo($oRequest, CURLINFO_HTTP_CODE);
            $error       = curl_error($oRequest);
            curl_close($oRequest);

            if ($iHttpStatus == 200) {

                $oResponse = json_decode($response);

                if ($editForm->isValid() && $oResponse->valid == true) {
                    $aResult['max_clients'] = $oResponse->max_clients;
                    $aResult['valid_until'] = $oResponse->valid_until;
                    $aResult['domain']      = $sDomain;

                    $aResult['success'] = true;
                    $aResult['message'] = $this->get("translator")->trans("license.update.successful");

                    // license valid, save new license-data
                    $oLicense->setValidUntil($aResult['valid_until']);
                    $oLicense->setMaxClients($aResult['max_clients']);
                    $oLicense->setDomain($sDomain);
                    $oLicense->save();
                } else {
                    $aResult['success'] = false;
                    $aResult['message'] = $this->get("translator")->trans("license.update.failed");
                    $aResult['valid_until'] = strtotime("1970-01-01");
                    $aResult['max_clients'] = 0;
                    $aResult['domain'] = "-";
                }


            } else {

                $aResult['max_clients'] = $oLicense->getMaxClients();
                $aResult['valid_until'] = strtotime($oLicense->getValidUntil());
                $aResult['domain']      = $sDomain;

                $aResult['success'] = false;
                $aResult['message'] = $this->get("translator")->trans("license.update.failed_lico");
            }


            $sResult  = json_encode($aResult);
            $response = new Response($sResult);
            $response->headers->set('Content-Type', 'application/json');

            return $response;
        }
31962
public function update(Request $request)
    {
        $this->validate($request, [
            'password' => 'required|confirmed|min:6',
        ]);

        $request->user()->update([
            'password' => bcrypt($request->password),
        ]);
    }
1181464
public function update(Request $request, $id)
    {
        $entry = $this->entriesRepository->getById($id, $this->resource);
        $this->validate($request, $this->validationRules($this->resource, $entry));

        $this->entriesRepository->update($id, $request, $this->resource);

        return redirect()->back()->with('success', 'Updated');
    }
1370484
public function update(Request $request, $id)
    {
        $response = $this->repository->update($id, $request->all());
        return Response::apiResponse([
            'data' => $response
        ]);

    }
625366
public function updateAction(Request $request, $id)
    {
        $em = $this->getDoctrine()->getManager();

        $permissionsGroup = $em->getRepository('ChillMainBundle:PermissionsGroup')->find($id);

        if (!$permissionsGroup) {
            throw $this->createNotFoundException('Unable to find PermissionsGroup entity.');
        }

        $editForm = $this->createEditForm($permissionsGroup);
        $editForm->handleRequest($request);

        if ($editForm->isValid()) {
            
            $em->flush();

            return $this->redirect($this->generateUrl('admin_permissionsgroup_edit', array('id' => $id)));
        }
        
        $deleteRoleScopesForm = array();
        foreach ($permissionsGroup->getRoleScopes() as $roleScope) {
            $deleteRoleScopesForm[$roleScope->getId()] = $this->createDeleteRoleScopeForm(
                    $permissionsGroup, $roleScope);
        }
        
        $addRoleScopesForm = $this->createAddRoleScopeForm($permissionsGroup);

        return $this->render('ChillMainBundle:PermissionsGroup:edit.html.twig', array(
            'entity'      => $permissionsGroup,
            'edit_form'   => $editForm->createView(),
            'expanded_roles' => $this->getExpandedRoles($permissionsGroup->getRoleScopes()->toArray()),
            'delete_role_scopes_form' => array_map( function($form) { 
                
                return $form->createView(); 
            }, $deleteRoleScopesForm),
            'add_role_scopes_form' => $addRoleScopesForm->createView()
        ));
    }
1331165
public function update(Request $request)
    {
        $role = Role::findOrFail($request->role_id);

        $role->name = $request->name;

        $role->update();

        return redirect('scaffold-roles');
    }
1195265
public function updateManyToOneAction(Request $request)
    {
        /** @var AbstractAdmin $admin */
        $admin = $this->getAdmin();

        $admin->checkAccess('edit');

        $em = $admin->getDoctrine()->getManager();

        $ids = $request->request->get('value');
        $id = $request->request->get('pk');
        $field = $request->request->get('field');

        $object = $admin->getObject($id);

        /** @var \Sonata\DoctrineORMAdminBundle\Model\ModelManager $mm */
        $mm = $admin->getModelManager();

        $ClassMetadata = $mm->getMetadata($admin->getClass());

        $associationMapping = $ClassMetadata->getAssociationMapping($field);

        $items = $em->getRepository($associationMapping['targetEntity'])->find($ids);

        \call_user_func([$object, 'set' . ucfirst($field)], $items);

        $admin->update($object);

        $result = [
        ];

        $associationAdmin = $admin->getAdminByClass($associationMapping['targetEntity']);

        $twigSonataAdminExtension = $admin->getContainer()->get('sonata.admin.twig.extension');

        $fieldDescription = $admin->getListFieldDescription($field);

        if ($items) {
            $result[] = [
                'id' => $items->getId(),
                'label' => $twigSonataAdminExtension->renderRelationElement($items, $fieldDescription),
                'edit_url' => $associationAdmin->generateObjectUrl('edit', $items),
            ];
        }

        return new JsonResponse([
            'items' => $result,
        ]);
    }
1209897
public function updateAction(Request $request, $id)
        {

            /** @var Customer $oCustomer */
            $oCustomer = CustomerQuery::create()->findOneById($id);

            if (count($oCustomer) === 0) {
                throw $this->createNotFoundException('Unable to find Customer entity.');
            }

            $deleteForm = $this->createDeleteForm($id);
            $editForm   = $this->createEditForm($oCustomer);
            $editForm->handleRequest($request);


            if ($editForm->isValid()) {


                $sLogoPath = $this->_handleLogoUpload($request, $oCustomer);
                $oCustomer->setLogo($sLogoPath);

                $oCustomer->save();

                return $this->redirect($this->generateUrl('backend_system_customer'));
            }

            return $this->render('SlashworksAppBundle:Customer:edit.html.twig', array(
                'entity'      => $oCustomer,
                'edit_form'   => $editForm->createView(),
                'delete_form' => $deleteForm->createView(),
            ));
        }
825311
public function update(Request $request)
    {
        $this->authorize('update', Settings::class);

        $this->validate($request, [
            'text_editor' => 'required|in:plain-text,markdown,wysiwyg',
            'public_url'  => 'required|max:255',
        ]);

        Settings::first()->update([
            'text_editor' => $request->input('text_editor'),
            'public_url'  => $request->input('public_url'),
        ]);

        return redirect()->route('laralum::settings.index', ['p' => 'Tickets'])
            ->with('success', __('laralum_tickets::general.tickets_settings_updated'));
    }
1128056
public function update(Request $request)
    {
        $output = $this->schemaManager()->update();
        $this->session()->set('dbupdate_result', $output->getResponseStrings());

        return $this->redirectToRoute('dbupdate_result');
    }
470953
public function update(Request $request, $id)
    {
        $model = (new Services\GroupsPermissionsService)->dataUpdate($id, $request->all());
        $route = config('acl.routes.groups-permissions.edit');
        return redirect()->route($route, $id)->with('success', 'Permissões atualizadas com sucesso');
    }
346550
public function moveAction(Request $request)
    {
        $admin = $this->getAdmin();

        $admin->checkAccess('edit');

        if ($admin->isChild()) {
            $id = $request->query->get('childId');
        } else {
            $id = $request->query->get('id');
        }

        $targetId = $request->query->get('target');
        $dropPosition = $request->query->get('position');

        $em = $this->getDoctrine()->getManager();

        /** @var NestedTreeRepository $repo */
        $repo = $em->getRepository($admin->getClass());

        $currentNode = $repo->find($id);
        $targetNode = $repo->find($targetId);

        switch ($dropPosition) {
            case 'before':
                $currentNode->setParent($targetNode->getParent());

                if ($targetNode->getPosition()) {
                    $currentNode->setPosition($targetNode->getPosition() - 1);
                } else {
                    $currentNode->setPosition(0);
                }
                break;
            case 'after':
                $currentNode->setParent($targetNode->getParent());
                $currentNode->setPosition($targetNode->getPosition() + 1);
                break;
            case 'append':
                $currentNode->setParent($targetNode);
                $currentNode->setPosition(-1);
                break;
        }

        $admin->update($currentNode);
        $admin->update($targetNode);

        return $this->renderJson(['result' => true]);
    }
836068
public function moveUpAction(Request $request)
    {
        $context = $this->loadContext($request);

        $resource = $context->getResource();

        $this->isGranted('EDIT', $resource);

        $repo = $this->getRepository();
        $repo->moveUp($resource, 1);

        return $this->redirectToReferer($this->generateUrl(
            $this->config->getRoute('list'),
            $context->getIdentifiers()
        ));
    }
1159047
public function update(Request $request, $id)
    {
        $name = \Transliteration::clean_filename(strtolower($request->label));
        $label = $request->label;

        try
        {
          WorkflowState::where('id',$id)->update(['label' => $label, 'name' => $name]);
        }
        catch(\Illuminate\Database\QueryException $e){
            // do what you want here with $e->getMessage();
            return redirect()->route('state')->with('message', 'Error');
        }

        return redirect()->route('state')->with('message', 'Update data success');
    }
1306198
public function updateSettings(Request $request)
    {
        $this->authorize('update', Settings::class);

        Settings::first()->update([
            'stripe_key'    => $request->stripe_key ? encrypt($request->stripe_key) : null,
            'stripe_secret' => $request->stripe_secret ? encrypt($request->stripe_secret) : null,
        ]);

        return redirect()->route('laralum::settings.index', ['p' => 'Payments'])->with('success', __('laralum_payments::general.updated_settings'));
    }
952498
public function updateImage(Request $request)
    {
        $fileName = $request->query->get('file');
        $type = $request->query->get('type');
        $value = $request->query->get('value');
      
        /** @var Image $entity */
        $qb = $this->getDoctrine()->getManager()->getRepository('CoreBundle:Image')
                ->createQueryBuilder('i');
        $image = $qb->where($qb->expr()->like('i.path', ':path'))
            ->setParameter('path','%'.$fileName.'%')
            ->getQuery()
            ->getOneOrNullResult();

//        $image = $this->getDoctrine()->getManager()->getRepository('CoreBundle:Image')->findOneBy(array('path' => $fileName));
       
        if (!$image) {
            throw new NotFoundHttpException('Unable to find Image entity.');
        }
        

        if($type == 'title') $image->setTitle($value);
        if($type == 'alt') $image->setAlt($value);
        
        $this->getDoctrine()->getManager()->flush();
            

        return new JsonResponse(array('success' => true));
    }
960184
public function update($id,Request $request)
    {
        $feature = Feature::findOrfail($id);
    	
        $feature->name = $request->name;
        
        $feature->description = $request->description;
        
        $feature->featuretype_id = $request->featuretype_id;

        $feature->demonstration_URL = $request->demonstration_URL;

        $feature->package_id = $request->package_id;       
        
        $feature->save();

        return redirect('feature');
    }