src/Controller/RoutesController.php
protected function _addDefaultRoute(array $routeData)
    {
        /** @var Connection $connection */
        $connection = $this->Routes->connection();
        $connection->begin();

        // Save the new default route.
        /** @var Route $defaultRoute */
        $defaultRoute = $this->Routes->newEntity($routeData);

        if ($this->Routes->save($defaultRoute)) {
            // Make all other routes for this model + foreignKey + languageId
            // redirect to the new default route.
            $otherRoutes = $this->Routes->getOtherRoutesExcept($defaultRoute->id, $defaultRoute->model, $defaultRoute->foreign_key, $defaultRoute->language_id);
            $this->Routes->redirectRoutesToId($otherRoutes, $defaultRoute->id);

            $connection->commit();
            $this->Flash->success(__d('wasabi_core', 'New default URL <strong>{0}</strong> has been added.', $defaultRoute->url), 'routes');
            $this->request->data = [];
        } else {
            $connection->rollback();
            $this->Flash->error($this->formErrorMessage, 'routes');
            $defaultRoute->set('type', RouteTypes::TYPE_DEFAULT_ROUTE);
        }

        return $defaultRoute;
    }
protected function _addDefaultRoute(array $routeData)
    {
        /** @var Connection $connection */
        $connection = $this->Routes->connection();
        $connection->begin();

        // Save the new default route.
        /** @var Route $defaultRoute */
        $defaultRoute = $this->Routes->newEntity($routeData);

        if ($this->Routes->save($defaultRoute)) {
            // Make all other routes for this model + foreignKey + languageId
            // redirect to the new default route.
            $otherRoutes = $this->Routes->getOtherRoutesExcept($defaultRoute->id, $defaultRoute->model, $defaultRoute->foreign_key, $defaultRoute->language_id);
            $this->Routes->redirectRoutesToId($otherRoutes, $defaultRoute->id);

            $connection->commit();
            $this->Flash->success(__d('wasabi_core', 'New default URL <strong>{0}</strong> has been added.', $defaultRoute->url), 'routes');
            $this->request->data = [];
        } else {
            $connection->rollback();
            $this->Flash->error($this->formErrorMessage, 'routes');
            $defaultRoute->set('type', RouteTypes::TYPE_DEFAULT_ROUTE);
        }

        return $defaultRoute;
    }
protected function _addDefaultRoute ( array $ routeData ) { /** @var Connection $connection */ $ connection = $ this -> Routes -> connection ( ) ; $ connection -> begin ( ) ; // Save the new default route. /** @var Route $defaultRoute */ $ defaultRoute = $ this -> Routes -> newEntity ( $ routeData ) ; if ( $ this -> Routes -> save ( $ defaultRoute ) ) { // Make all other routes for this model + foreignKey + languageId // redirect to the new default route. $ otherRoutes = $ this -> Routes -> getOtherRoutesExcept ( $ defaultRoute -> id , $ defaultRoute -> model , $ defaultRoute -> foreign_key , $ defaultRoute -> language_id ) ; $ this -> Routes -> redirectRoutesToId ( $ otherRoutes , $ defaultRoute -> id ) ; $ connection -> commit ( ) ; $ this -> Flash -> success ( __d ( 'wasabi_core' , 'New default URL <strong>{0}</strong> has been added.' , $ defaultRoute -> url ) , 'routes' ) ; $ this -> request -> data = [ ] ; } else { $ connection -> rollback ( ) ; $ this -> Flash -> error ( $ this -> formErrorMessage , 'routes' ) ; $ defaultRoute -> set ( 'type' , RouteTypes :: TYPE_DEFAULT_ROUTE ) ; } return $ defaultRoute ; }
Add a new default route.

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