src/Controller/RoutesController.php
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;
    }
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;
    }
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 ; }
Add a new redirect route.

@param array $routeData The route data.
@return Route
Add a new redirect route .