src/Controller/RoutesController.php
public function makeDefault($id)
    {
        if (!$this->request->isAll(['ajax', 'post'])) {
            throw new MethodNotAllowedException();
        }

        /** @var Route $route */
        $route = $this->Routes->get($id);

        /** @var Connection $connection */
        $connection = $this->Routes->connection();
        $connection->begin();

        $route->set([
            'redirect_to' => null,
            'status_code' => null
        ]);
        if ($this->Routes->save($route)) {
            $otherRoutes = $this->Routes->getOtherRoutesExcept($route->id, $route->model, $route->foreign_key, $route->language_id);
            $this->Routes->redirectRoutesToId($otherRoutes, $route->id);

            $connection->commit();
            $this->Flash->success(__d('wasabi_core', '<strong>{0}</strong> is now the new Default Route.', $route->url), 'routes');
        } else {
            $connection->rollback();
            $this->Flash->error($this->dbErrorMessage, 'routes');
        }

        $this->_render($route, $this->request->query('element'));
    }
public function makeDefault($id)
    {
        if (!$this->request->isAll(['ajax', 'post'])) {
            throw new MethodNotAllowedException();
        }

        /** @var Route $route */
        $route = $this->Routes->get($id);

        /** @var Connection $connection */
        $connection = $this->Routes->connection();
        $connection->begin();

        $route->set([
            'redirect_to' => null,
            'status_code' => null
        ]);
        if ($this->Routes->save($route)) {
            $otherRoutes = $this->Routes->getOtherRoutesExcept($route->id, $route->model, $route->foreign_key, $route->language_id);
            $this->Routes->redirectRoutesToId($otherRoutes, $route->id);

            $connection->commit();
            $this->Flash->success(__d('wasabi_core', '<strong>{0}</strong> is now the new Default Route.', $route->url), 'routes');
        } else {
            $connection->rollback();
            $this->Flash->error($this->dbErrorMessage, 'routes');
        }

        $this->_render($route, $this->request->query('element'));
    }
public function makeDefault ( $ id ) { if ( ! $ this -> request -> isAll ( [ 'ajax' , 'post' ] ) ) { throw new MethodNotAllowedException ( ) ; } /** @var Route $route */ $ route = $ this -> Routes -> get ( $ id ) ; /** @var Connection $connection */ $ connection = $ this -> Routes -> connection ( ) ; $ connection -> begin ( ) ; $ route -> set ( [ 'redirect_to' => null , 'status_code' => null ] ) ; if ( $ this -> Routes -> save ( $ route ) ) { $ otherRoutes = $ this -> Routes -> getOtherRoutesExcept ( $ route -> id , $ route -> model , $ route -> foreign_key , $ route -> language_id ) ; $ this -> Routes -> redirectRoutesToId ( $ otherRoutes , $ route -> id ) ; $ connection -> commit ( ) ; $ this -> Flash -> success ( __d ( 'wasabi_core' , '<strong>{0}</strong> is now the new Default Route.' , $ route -> url ) , 'routes' ) ; } else { $ connection -> rollback ( ) ; $ this -> Flash -> error ( $ this -> dbErrorMessage , 'routes' ) ; } $ this -> _render ( $ route , $ this -> request -> query ( 'element' ) ) ; }
MakeDefault action
AJAX POST

@param int|string $id The route id.
@return void
MakeDefault action AJAX POST