Simple implementation add or edit object

@param array $data
@param bool $redirect
777190
protected function addOrEditObject($data = [], $redirect = TRUE)
	{
		try {
			if ($this->detailObject) {
				// Edit object
				$this->canUser('edit');
				$this->mainManager->edit($this->detailObject->id, $data);
				$this->flashMessage('Object saved');

			} else {
				// Add object
				$this->canUser('add');
				$this->mainManager->add($data);
				$this->flashMessage('Object added');
			}

		} catch (\Exception $e) {
			$this->flashMessage('Upps.', 'error');
		}

		if ($redirect) {
			$this->redirect('default');
		}

	}
382483
public function setRedirectUrl($redirect = null, $key = null) {
		if (empty($redirect)) {
			$redirect = $this->_controller->request->referer(true);
		} elseif ($redirect === true) {
			$redirect = $this->_controller->request->here(true);
		}
		if (empty($redirect) || $this->_controller->request->is('popup') ||
			$this->_controller->request->is('print')) {
			return false;
		}
		$cacheKey = $this->_getSessionKeyRedirect($key);
		$data = CakeSession::read($cacheKey);
		if (!empty($data) && (md5((string)$data) === md5((string)$redirect))) {
			return false;
		}

		return CakeSession::write($cacheKey, $redirect);
	}
785172
public function post($url, array $data = [])
    {
        $this->setopt(CURLOPT_URL, $url);
        $this->setopt(CURLOPT_POST, true);
        $data = http_build_query($data);
        $this->setopt(CURLOPT_POSTFIELDS, $data);
        $this->_exec();
    }
134775
public function doAdd($data, $form)
    {
        if ($this->addMember($form)) {
            $form->sessionMessage(
                _t('MemberProfiles.MEMBERADDED', 'The new member has been added.'),
                'good'
            );
        }

        return $this->redirectBack();
    }
1246499
public function doAddMockData($data, $form)
    {
        $this->owner->record->fill(array(
            'only_empty' => true,
            'include_relations' => false,
            'download_images' => false
        ));

        Controller::curr()->getResponse()->addHeader("X-Pjax", "Content");
        $link = Controller::join_links($this->owner->gridField->Link(), "item", $this->owner->record->ID);
        return Controller::curr()->redirect($link);
    }
67230
public function post($url, $data)
	{
		$this->init($url);
		$this->setPost($data);
		$this->exec();
		$this->fin();
	}
49659
protected function _addRedirectRoute($routeData)
    {
        /** @var Route $defaultRoute */
        $defaultRoute = $this->Routes->getDefaultRoute($routeData['model'], $routeData['foreign_key'], $routeData['language_id']);
        /** @var Route $redirectRoute */
        $redirectRoute = $this->Routes->newEntity($routeData);

        if (!empty($defaultRoute)) {
            $redirectRoute->set('redirect_to', $defaultRoute->id);
            $redirectRoute->set('status_code', 301);
            if ($this->Routes->save($redirectRoute)) {
                $this->Flash->success(__d('wasabi_core', 'New redirect URL <strong>{0}</strong> has been added.', $redirectRoute->url), 'routes');
                $this->request->data = [];
            } else {
                $this->Flash->error($this->formErrorMessage, 'routes');
                $redirectRoute->set('type', RouteTypes::TYPE_REDIRECT_ROUTE);
            }
        } else {
            $this->Flash->error(__d('wasabi_core', 'Please create a default route first.'), 'routes');
            $redirectRoute->set('type', RouteTypes::TYPE_REDIRECT_ROUTE);
        }

        return $redirectRoute;
    }
1232721
protected function incrementHitCount(array $redirectRecord)
    {
        // Track the hit if not disabled
        if (!GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('redirects.hitCount') || $redirectRecord['disable_hitcount']) {
            return;
        }
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
            ->getQueryBuilderForTable('sys_redirect');
        $queryBuilder
            ->update('sys_redirect')
            ->where(
                $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($redirectRecord['uid'], \PDO::PARAM_INT))
            )
            ->set('hitcount', $queryBuilder->quoteIdentifier('hitcount') . '+1', false)
            ->set('lasthiton', $GLOBALS['EXEC_TIME'])
            ->execute();
    }
587446
public function setRedirectPostData($aRedirectPostData)
    {
        if (!$this->bIsLocked) {
            $this->aRedirectPostData = $aRedirectPostData;
            $this->setIsRedirect(!empty($aRedirectPostData));
        }
        return $this;
    }
1262834
public function handleEdit(int $redirectId) : void
    {
        if ($this->presenter->isAjax())
        {
            $this->redirectId = $redirectId;
            $this->onEdit();
        }
    }
811881
public function postRedirect(string $url = null, array $data = []) : void
    {
        $this->postRedirectUrl = $url;
        $this->postRedirectData = $data;
    }
318126
public function addHeader($name,$required,$data) {

            $this->amfResponse->addHeader(array('name'=>$name,'required'=>$required==true,'data'=>$data));

        }
1327942
public function put($url, array $data = [])
    {
        $this->setopt(CURLOPT_URL, $url.'?'.http_build_query($data));
        $this->setopt(CURLOPT_CUSTOMREQUEST, 'PUT');
        $this->_exec();
    }
332599
function addData($data, $col_id = 0, $row_id = 0) {
        foreach ($data as $row) {
            if ($row === self::CONSOLE_TABLE_HORIZONTAL_RULE) {
                $this->_data[$row_id] = self::CONSOLE_TABLE_HORIZONTAL_RULE;
                $row_id++;
                continue;
            }
            $starting_col = $col_id;
            foreach ($row as $cell) {
                $this->_data[$row_id][$starting_col++] = $cell;
            }
            $this->_updateRowsCols();
            $this->_max_cols = max($this->_max_cols, $starting_col);
            $row_id++;
        }
    }
1270121
public function doSubmit($data, $form) {
		$controller = Controller::curr();

		$redirect = Director::baseURL() . $this->owner->URLSegment;

		if ((bool) Config::inst()->get('QuickFeedbackExtension', 'redirect_field') && isset($data['Redirect']) && Director::is_site_url($data['Redirect'])) {
			$redirect = Director::absoluteURL($data['Redirect'], true);
		}

		if (!$controller) {
			goto error;
		}

		$request = $controller->getRequest();

		if (!$request) {
			goto error;
		}

		$limit = (int) Config::inst()->get('QuickFeedbackExtension', 'rate_limit');

		$existing = Feedback::get()
			->filter('IP', $request->getIP())
			->sort('Created desc')
			->first();

		if ($existing) {
			$created = $existing->dbObject('Created');

			if (!$created) {
				goto error;
			}

			$seconds = abs(time() - strtotime($created->getValue()));
			$minutes = round($seconds / 60);

			if ($minutes <= $limit) {
				goto rate;
			}
		}

		$feedback = Feedback::create();
		$feedback->Rating = $data['Rating'];
		$feedback->Comment = $data['Comment'];
		$feedback->IP = $request->getIP();

		if (!empty($this->owner->ID)) {
			$feedback->PageID = $this->owner->ID;
		}

		if (!empty($this->owner->URLSegment)) {
			$feedback->URL = $this->owner->RelativeLink();
		}

		if ((bool) Config::inst()->get('QuickFeedbackExtension', 'redirect_field') && isset($data['Redirect'])) {
			$feedback->URL = $data['Redirect'];
		}

		$feedback->write();

		$form->sessionMessage(_t('QuickFeedback.ThanksMessage', 'Thanks for your comment!'),'good');
		return $this->owner->redirect($redirect . '?success=1#Form_QuickFeedbackForm');

		error:
			$form->sessionMessage(_t('QuickFeedback.ErrorMessage', 'An error occurred!'),'error');
			return $this->owner->redirect($redirect . '?error=1#Form_QuickFeedbackForm');

		rate:
			$form->sessionMessage(_t('QuickFeedback.RateMessage', 'Please wait a while before submitting!'),'error');
			return $this->owner->redirect($redirect . '?rate=1#Form_QuickFeedbackForm');
	}
648860
public function addRedirect($postValues)
    {
        $redirectObject = RedirectsFactory::createRedirectFromPostValues($postValues);
        $redirects = $this->repository->redirects;
        $redirects[] = $redirectObject;
        $this->repository->redirects = $redirects;
        $this->save();
    }
1174034
protected function redirectToSuccess(array $data)
    {
        $link = $this->link('passwordsent');

        return $this->redirect($this->addBackURLParam($link));
    }