/** * Function to create default routes CRUD * * @static * @access public * @param string $sRouteName * @param string $sController * @return void */ public static function CRUD($sRouteName, $sController) { if (method_exists($sController, "Index")) { Routes::Set($sRouteName, "GET", $sController . "::Index"); } if (method_exists($sController, "CRUDInsert")) { Routes::Set($sRouteName, "POST", array($sController . "::CRUDInsert", new $sController())); } if (method_exists($sController, "CRUDEdit")) { Routes::Set($sRouteName . "/{id}", "GET", array($sController . "::CRUDEdit", new $sController())); } if (method_exists($sController, "CRUDUpdate")) { Routes::Set($sRouteName . "/{id}", "PUT", array($sController . "::CRUDUpdate", new $sController())); } if (method_exists($sController, "CRUDDestroy")) { Routes::Set($sRouteName . "/{id}", "DELETE", array($sController . "::CRUDDestroy", new $sController())); } }
<?php /** * Routes of Hello World * * @package MagicPHP Hello World * @author André Ferreira <*****@*****.**> * @link https://github.com/magicphp/magicphp MagicPHP(tm) * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ Routes::SetOverloadFrontend(true); Routes::Set("", "GET", "App\\Helloworld\\Controllers\\Helloworld::Index"); Routes::SetDynamicRoute(function () { Output::SendHTTPCode(404); });