save

@param RedirectEntity $redirect

@return void
774799
public function save(
        RedirectEntity $redirect
    ) {
        /** @var \Rcm\Entity\Redirect $result */
        $result = $this->findOneBy(
            [
                'requestUrl' => $redirect->getRequestUrl(),
                'redirectUrl' => $redirect->getRedirectUrl(),
                'siteId' => $redirect->getSiteId(),
            ]
        );

        if (!empty($result) && $result->getRedirectId() !== $redirect->getRedirectId()) {
            throw new RedirectException('Duplicate redirects not allowed');
        }

        if ($redirect->getSiteId() !== null) {
            $siteRepo = $this->getEntityManager()->getRepository(
                \Rcm\Entity\Site::class
            );

            $site = $siteRepo->find($redirect->getSiteId());

            if (empty($site)) {
                throw new RedirectException('Valid site required');
            }
            $redirect->setSite($site);
        }

        $this->getEntityManager()->persist($redirect);
        $this->getEntityManager()->flush($redirect);
    }
1108856
public function save($entity)
    {

        $objectManager = $this->getObjectManager();

        //@TODO UnitOfWork::STATE_NEW == $em->getUnitOfWork()->getEntityState($entity)
        //@see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/working-with-objects.html#entity-state
        $objectManager->persist($entity);
        $objectManager->flush();
    }
323671
private function Configure($RedirectUrl = '') {
      // Create a model to save configuration settings
      $Validation = new Gdn_Validation();
      $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
      $ConfigurationModel->SetField(array('Garden.Locale', 'Garden.Title', 'Garden.RewriteUrls', 'Garden.WebRoot', 'Garden.Cookie.Salt', 'Garden.Cookie.Domain', 'Database.Name', 'Database.Host', 'Database.User', 'Database.Password', 'Garden.Registration.ConfirmEmail', 'Garden.Email.SupportName'));
      
      // Set the models on the forms.
      $this->Form->SetModel($ConfigurationModel);
      
      // Load the locales for the locale dropdown
      // $Locale = Gdn::Locale();
      // $AvailableLocales = $Locale->GetAvailableLocaleSources();
      // $this->LocaleData = array_combine($AvailableLocales, $AvailableLocales);
      
      // If seeing the form for the first time...
      if (!$this->Form->IsPostback()) {
         // Force the webroot using our best guesstimates
         $ConfigurationModel->Data['Database.Host'] = 'localhost';
         $this->Form->SetData($ConfigurationModel->Data);
      } else {         
         // Define some validation rules for the fields being saved
         $ConfigurationModel->Validation->ApplyRule('Database.Name', 'Required', 'You must specify the name of the database in which you want to set up Vanilla.');
			
         // Let's make some user-friendly custom errors for database problems
         $DatabaseHost = $this->Form->GetFormValue('Database.Host', '~~Invalid~~');
         $DatabaseName = $this->Form->GetFormValue('Database.Name', '~~Invalid~~');
         $DatabaseUser = $this->Form->GetFormValue('Database.User', '~~Invalid~~');
         $DatabasePassword = $this->Form->GetFormValue('Database.Password', '~~Invalid~~');
         $ConnectionString = GetConnectionString($DatabaseName, $DatabaseHost);
         try {
            $Connection = new PDO(
               $ConnectionString,
               $DatabaseUser,
               $DatabasePassword
            );
         } catch (PDOException $Exception) {
            switch ($Exception->getCode()) {
               case 1044:
                  $this->Form->AddError(T('The database user you specified does not have permission to access the database. Have you created the database yet? The database reported: <code>%s</code>'), strip_tags($Exception->getMessage()));
                  break;
               case 1045:
                  $this->Form->AddError(T('Failed to connect to the database with the username and password you entered. Did you mistype them? The database reported: <code>%s</code>'), strip_tags($Exception->getMessage()));
                  break;
               case 1049:
                  $this->Form->AddError(T('It appears as though the database you specified does not exist yet. Have you created it yet? Did you mistype the name? The database reported: <code>%s</code>'), strip_tags($Exception->getMessage()));
                  break;
               case 2005:
                  $this->Form->AddError(T("Are you sure you've entered the correct database host name? Maybe you mistyped it? The database reported: <code>%s</code>"), strip_tags($Exception->getMessage()));
                  break;
               default:
                  $this->Form->AddError(sprintf(T('ValidateConnection'), strip_tags($Exception->getMessage())));
               break;
            }
         }
			
         $ConfigurationModel->Validation->ApplyRule('Garden.Title', 'Required');
         
         $ConfigurationFormValues = $this->Form->FormValues();
         if ($ConfigurationModel->Validate($ConfigurationFormValues) !== TRUE || $this->Form->ErrorCount() > 0) {
            // Apply the validation results to the form(s)
            $this->Form->SetValidationResults($ConfigurationModel->ValidationResults());
         } else {
            $Host = array_shift(explode(':',Gdn::Request()->RequestHost()));
            $Domain = Gdn::Request()->Domain();

            // Set up cookies now so that the user can be signed in.
            $ExistingSalt = C('Garden.Cookie.Salt', FALSE);
            $ConfigurationFormValues['Garden.Cookie.Salt'] = ($ExistingSalt) ? $ExistingSalt : RandomString(10);
            $ConfigurationFormValues['Garden.Cookie.Domain'] = ''; // Don't set this to anything by default. # Tim - 2010-06-23
            // Additional default setup values.
            $ConfigurationFormValues['Garden.Registration.ConfirmEmail'] = TRUE;
            $ConfigurationFormValues['Garden.Email.SupportName'] = $ConfigurationFormValues['Garden.Title'];

            $ConfigurationModel->Save($ConfigurationFormValues, TRUE);
                    
            // If changing locale, redefine locale sources:
            $NewLocale = 'en-CA'; // $this->Form->GetFormValue('Garden.Locale', FALSE);
            if ($NewLocale !== FALSE && Gdn::Config('Garden.Locale') != $NewLocale) {
               $ApplicationManager = new Gdn_ApplicationManager();
               $Locale = Gdn::Locale();
               $Locale->Set($NewLocale, $ApplicationManager->EnabledApplicationFolders(), Gdn::PluginManager()->EnabledPluginFolders(), TRUE);
            }

            // Install db structure & basic data.
            $Database = Gdn::Database();
            $Database->Init();
            $Drop = FALSE; // Gdn::Config('Garden.Version') === FALSE ? TRUE : FALSE;
            $Explicit = FALSE;
            try {
               include(PATH_APPLICATIONS . DS . 'dashboard' . DS . 'settings' . DS . 'structure.php');
            } catch (Exception $ex) {
               $this->Form->AddError($ex);
            }
         
            if ($this->Form->ErrorCount() > 0)
               return FALSE;

            // Create the administrative user
            $UserModel = Gdn::UserModel();
            $UserModel->DefineSchema();
            $UsernameError = T('UsernameError', 'Username can only contain letters, numbers, underscores, and must be between 3 and 20 characters long.');
            $UserModel->Validation->ApplyRule('Name', 'Username', $UsernameError);
            $UserModel->Validation->ApplyRule('Name', 'Required', T('You must specify an admin username.'));
            $UserModel->Validation->ApplyRule('Password', 'Required', T('You must specify an admin password.'));
            $UserModel->Validation->ApplyRule('Password', 'Match');
            $UserModel->Validation->ApplyRule('Email', 'Email');
            
            if (!($AdminUserID = $UserModel->SaveAdminUser($ConfigurationFormValues))) {
               $this->Form->SetValidationResults($UserModel->ValidationResults());
            } else {
               // The user has been created successfully, so sign in now.
               SaveToConfig('Garden.Installed', TRUE, array('Save' => FALSE));
               Gdn::Session()->Start($AdminUserID, TRUE);
               SaveToConfig('Garden.Installed', FALSE, array('Save' => FALSE));
            }
            
            if ($this->Form->ErrorCount() > 0)
               return FALSE;
            
            // Assign some extra settings to the configuration file if everything succeeded.
            $ApplicationInfo = array();
            include(CombinePaths(array(PATH_APPLICATIONS . DS . 'dashboard' . DS . 'settings' . DS . 'about.php')));
            
            // Detect rewrite abilities
            $CanRewrite = (bool)$this->Form->GetFormValue('RewriteUrls');
      
            SaveToConfig(array(
               'Garden.Version' => ArrayValue('Version', GetValue('Dashboard', $ApplicationInfo, array()), 'Undefined'),
               'Garden.RewriteUrls' => $CanRewrite,
               'Garden.CanProcessImages' => function_exists('gd_info'),
               'EnabledPlugins.GettingStarted' => 'GettingStarted', // Make sure the getting started plugin is enabled
               'EnabledPlugins.HtmLawed' => 'HtmLawed' // Make sure html purifier is enabled so html has a default way of being safely parsed.
            ));
         }
      }
      return $this->Form->ErrorCount() == 0 ? TRUE : FALSE;
   }
150867
public static function doRedirect($location) {
        if ( headers_sent() ) {
            // TODO: Check if this is fixed in PHP 70200
            // https://bugs.php.net/bug.php?id=74892
            if ( PHP_VERSION_ID >= 70000 ) {
                $location = U::addSession($location);
            }
            echo('<a href="'.$location.'">Continue</a>'."\n");
        } else {
            if ( ini_get('session.use_cookies') == 0 ) {
                $location = U::addSession($location);
            }
            header("Location: $location");
        }
    }
639933
public function save(Request $request, EntityContract $type, Post $post): RedirectResponse
    {
        $this->checkPermission(Post::POST_PERMISSION_PREFIX.$type->slug);
        $type->isValid();

        $post->fill($request->all())->fill([
            'type'    => $type->slug,
            'user_id' => $request->user()->id,
            'options' => $post->getOptions(),
        ]);

        $type->save($post);

        Alert::success(__('Operation completed successfully.'));

        $route = is_a($type, Many::class)
            ? 'platform.entities.type'
            : 'platform.entities.type.page';

        return redirect()->route($route, [
            'type' => $post->type,
            'slug' => $post->slug,
        ]);
    }
1262834
public function handleEdit(int $redirectId) : void
    {
        if ($this->presenter->isAjax())
        {
            $this->redirectId = $redirectId;
            $this->onEdit();
        }
    }
1368283
public function handleOpen(int $redirectId) : void
    {
        if ($this->presenter->isAjax())
        {
            $this->redirectEntity = $this->onPageRepository->findOneRedirectById($redirectId);

            $this->presenter->handleModalToggle('show', '#wakers_onpage_redirect_remove_modal', FALSE);

            $this->onOpen();
        }
    }
364959
public function setRedirect($redirect) {
        if (!is_bool($redirect)) throw new IllegalTypeException('Illegal type of parameter $redirect: '.gettype($redirect));

        $this->redirect = $redirect;
        return $this;
    }
1076025
public function saveWizard(Request $request, Redirector $redirect)
    {
        if (!file_exists('core/database.sql')) {
            session()->flash('message', 'Some file are missing, Please Contact Support. Send an email to software@thesoftking.com');
            return redirect()->back();
        }

        $rules = config('installer.environment.form.rules');
        $messages = [
            'environment_custom.required_if' => trans('installer_messages.environment.wizard.form.name_required'),
        ];

        $validator = Validator::make($request->all(), $rules, $messages);

        if ($validator->fails()) {
            $errors = $validator->errors();
            return view('vendor.installer.environment-wizard', compact('errors', 'envConfig'));
        }

        $response = file_get_contents('http://thesoftking.com/verify/api.php?code='.$request->envato_purchase_code.'&user='.$request->envato_username.'&domain='.$request->app_url);
        $data = json_decode($response);

        
        //Create connection
        $conn = @mysqli_connect($request->database_hostname, $request->database_username, $request->database_password);

        // Check connection
        if (!$conn) {
            session()->flash('message', 'Something wrong to your datbase conncetion information');
            return redirect()->back();
        }

        $db_selected = mysqli_select_db($conn,$request->database_name);
        if (!$db_selected) {

            session()->flash('message', 'Input database name not found in your server!');
            return redirect()->back();
        }   

        mysqli_close($conn);

        if(!$data->status=='Error'){
            session()->flash('message', $data->message);
            return redirect()->back();
        }

        $results = $this->EnvironmentManager->saveFileWizard($request);

        return $redirect->route('LaravelInstaller::database')
                        ->with(['results' => $results]);
    }
1287990
public function save(EntityInterface $entity)
    {
        $entity = $this->beforeSave($entity);

        $this->getEntityManager()->persist($entity);
        $this->getEntityManager()->flush($entity);

        $this->afterSave($entity);
    }
611796
public function save(AbstractEntity $entity)
    {
        if (empty($entity->getId())) {
            $this->getEntityManager()->persist($entity);
        }
        $this->getEntityManager()->flush($entity);
    }
399130
public function store(Request $request)
    {
        $data = $this->validate(request(), [
            'old_url' => 'required',
            'new_url' => 'required'
        ]);

        Redirection::create($data);

        session()->flash('success', 'Redirección registrada con éxito!');
        return redirect()->route('redirecciones.index');
    }
1168103
private function save(RedirectRouteInterface $entity)
    {
        $this->manager->save($entity);

        if (0 === count($this->sources) % $this->batchSize) {
            $this->entityManager->flush();
        }
    }
936874
public static function permanentRedirect($url, $externalRedirect = false) {
		/** @var Response $response */
		$response = new static();
		$response->redirect($url, $externalRedirect, self::HTTP_PERMANENT_REDIRECT);
		return $response;
	}
585632
public function delete(Redirect $redirect)
    {
        $endpoint = '/admin/redirect/'.$redirect->id.'.json';
        $response = $this->request($endpoint, 'DELETE');
        return;
    }
1354828
public function store(CreateRedirectRequest $request)
    {
        $this->authorize(RedirectsPolicy::PERMISSION_CREATE);

        $redirect = Redirect::createRedirect(
            $request->getValidatedData()
        );

        $this->transNotification('created', [], $redirect->toArray());

        return redirect()->route('admin::seo.redirects.show', [$redirect]);
    }
969339
public function setRedirectView($redirectView)
    {
        if (!is_file($redirectView)) {
            throw new \RuntimeException(sprintf('Redirect view file "%s" not found', $redirectView));
        }
        $this->redirectView = $redirectView;
        return $this;
    }