public static function getInstance(Router $router) { $name = $router->getController(); $ver = $router->getVersion(); if (is_readable(__DIR__ . "/v{$ver}/{$name}.php")) { require_once __DIR__ . "/v{$ver}/{$name}.php"; //$name = '\\Api\\Controllers\\' . $name; return new $name(View::getInstance($router), $router->getParams()); } else { throw new Exception(Exception::ROUTER_WRONG_CONTROLLER); } }
public static function getInstance(Router $router) { switch ($router->getFormat()) { case self::FORMAT_REST: require_once __DIR__ . '/REST.php'; return new REST($sl); case self::FORMAT_REST_JSON: require_once __DIR__ . '/REST.php'; require_once __DIR__ . '/REST/JSON.php'; return new REST\JSON($sl); case self::FORMAT_REST_XML: require_once __DIR__ . '/REST.php'; require_once __DIR__ . '/REST/XML.php'; return new REST\XML($sl); } }