FOF30\Controller\DataController::cancel PHP Method

cancel() public method

Cancel the edit, check in the record and return to the Browse task
public cancel ( ) : void
return void
    public function cancel()
    {
        $model = $this->getModel()->savestate(false);
        if (!$model->getId()) {
            $this->getIDsFromRequest($model, true);
        }
        if ($model->getId()) {
            $userId = $this->container->platform->getUser()->id;
            if ($model->isLocked($userId)) {
                try {
                    $model->checkIn($userId);
                } catch (LockedRecord $e) {
                    // Redirect to the display task
                    if ($customURL = $this->input->getBase64('returnurl', '')) {
                        $customURL = base64_decode($customURL);
                    }
                    $url = !empty($customURL) ? $customURL : 'index.php?option=' . $this->container->componentName . '&view=' . $this->container->inflector->pluralize($this->view) . $this->getItemidURLSuffix();
                    $this->setRedirect($url, $e->getMessage(), 'error');
                }
            }
            $model->unlock();
        }
        // Remove any saved data
        $sessionKey = $this->viewName . '.savedata';
        $this->container->session->set($sessionKey, null, $this->container->componentName);
        // Redirect to the display task
        if ($customURL = $this->input->getBase64('returnurl', '')) {
            $customURL = base64_decode($customURL);
        }
        $url = !empty($customURL) ? $customURL : 'index.php?option=' . $this->container->componentName . '&view=' . $this->container->inflector->pluralize($this->view) . $this->getItemidURLSuffix();
        $this->setRedirect($url);
    }