-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #421 from tdt/development
Development
- Loading branch information
Showing
15 changed files
with
361 additions
and
241 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
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,40 @@ | ||
<?php | ||
|
||
namespace Tdt\Core; | ||
|
||
class Controller extends \Controller | ||
{ | ||
/** | ||
* Process the URI and return the extension (=format) and the resource identifier URI | ||
* | ||
* @param string $uri The URI that has been passed | ||
* @return array | ||
*/ | ||
public static function processURI($uri) | ||
{ | ||
$dot_position = strrpos($uri, '.'); | ||
|
||
if (! $dot_position) { | ||
return array($uri, null); | ||
} | ||
|
||
// If a dot has been found, do a couple | ||
// of checks to find out if it introduces a formatter | ||
$uri_parts = explode('.', $uri); | ||
|
||
$possible_extension = strtoupper(array_pop($uri_parts)); | ||
|
||
$uri = implode('.', $uri_parts); | ||
|
||
$formatter_class = 'Tdt\\Core\\Formatters\\' . $possible_extension . 'Formatter'; | ||
|
||
if (! class_exists($formatter_class)) { | ||
// Re-attach the dot with the latter part of the uri | ||
$uri .= '.' . strtolower($possible_extension); | ||
|
||
return array($uri, null); | ||
} | ||
|
||
return array($uri, strtolower($possible_extension)); | ||
} | ||
} |
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
Oops, something went wrong.