-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved action checks and setting to RESTful_Core::route_filter() to be…
… used when filtering api request routes closes #19
- Loading branch information
Showing
3 changed files
with
69 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php defined('SYSPATH') or die('No direct script access.'); | ||
|
||
class RESTful extends RESTful_Core {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php defined('SYSPATH') or die('No direct script access.'); | ||
/** | ||
* @package RESTful | ||
* @author Michał Musiał | ||
* @copyright (c) 2013 Michał Musiał | ||
*/ | ||
class RESTful_Core { | ||
|
||
/** | ||
* Filters RESTful Route. Sets <resource> as controller name and maps | ||
* Request method with appropriate action name. | ||
* | ||
* @param Route $route | ||
* @param array $params | ||
* @param Request $request | ||
* @return array | ||
*/ | ||
public static function route_filter($route, $params, $request) | ||
{ | ||
// Override method if appropriate header provided | ||
if ($method_override = $request->headers('X-HTTP-Method-Override')) | ||
{ | ||
$request->method($method_override); | ||
} | ||
|
||
$params['controller'] = $params['resource']; | ||
$params['action'] = RESTful_Controller::$action_map[strtoupper($request->method())]; | ||
|
||
return $params; | ||
} | ||
} |