| Code Coverage | ||||||||||
| Lines | Functions and Methods | Classes and Traits | ||||||||
| Total |  | 0.00% | 0 / 9 |  | 0.00% | 0 / 2 | CRAP |  | 0.00% | 0 / 1 | 
| LegacyRoute |  | 0.00% | 0 / 9 |  | 0.00% | 0 / 2 | 56 |  | 0.00% | 0 / 1 | 
| resolve |  | 0.00% | 0 / 8 |  | 0.00% | 0 / 1 | 42 | |||
| getControllerPrefix |  | 0.00% | 0 / 1 |  | 0.00% | 0 / 1 | 2 | |||
| 1 | <?php | 
| 2 | |
| 3 | /** | 
| 4 | * This program is free software; you can redistribute it and/or | 
| 5 | * modify it under the terms of the GNU General Public License | 
| 6 | * as published by the Free Software Foundation; under version 2 | 
| 7 | * of the License (non-upgradable). | 
| 8 | * | 
| 9 | * This program is distributed in the hope that it will be useful, | 
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| 12 | * GNU General Public License for more details. | 
| 13 | * | 
| 14 | * You should have received a copy of the GNU General Public License | 
| 15 | * along with this program; if not, write to the Free Software | 
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
| 17 | * | 
| 18 | * Copyright (c) 2014 (original work) Open Assessment Technologies SA; | 
| 19 | * | 
| 20 | * | 
| 21 | */ | 
| 22 | |
| 23 | namespace oat\tao\model\routing; | 
| 24 | |
| 25 | use Psr\Http\Message\ServerRequestInterface; | 
| 26 | |
| 27 | /** | 
| 28 | * A simple router, that maps a relative Url to | 
| 29 | * namespaced Controller class | 
| 30 | * | 
| 31 | * @author Joel Bout, <joel@taotesting.com> | 
| 32 | */ | 
| 33 | class LegacyRoute extends AbstractRoute | 
| 34 | { | 
| 35 | public function resolve(ServerRequestInterface $request) | 
| 36 | { | 
| 37 | $relativeUrl = \tao_helpers_Request::getRelativeUrl($request->getRequestTarget()); | 
| 38 | $parts = explode('/', ltrim($relativeUrl, '/')); | 
| 39 | if ($parts[0] == $this->getId()) { | 
| 40 | $controllerShortName = isset($parts[1]) && !empty($parts[1]) ? $parts[1] : DEFAULT_MODULE_NAME; | 
| 41 | $controller = $this->getExtension()->getId() . '_actions_' . $controllerShortName; | 
| 42 | $action = isset($parts[2]) && !empty($parts[2]) ? $parts[2] : DEFAULT_ACTION_NAME; | 
| 43 | return $controller . '@' . $action; | 
| 44 | } | 
| 45 | return null; | 
| 46 | } | 
| 47 | |
| 48 | /** | 
| 49 | * Get controller namespace prefix | 
| 50 | * @return string | 
| 51 | */ | 
| 52 | public static function getControllerPrefix() | 
| 53 | { | 
| 54 | return ''; | 
| 55 | } | 
| 56 | } |