forked from are0h/tapes
		
	
		
			
	
	
		
			34 lines
		
	
	
	
		
			747 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			34 lines
		
	
	
	
		
			747 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| 
								 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								namespace brain\controllers;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								class APIController
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    protected $tapes;
							 | 
						||
| 
								 | 
							
								    public function __construct()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $this->tapes = new TapesAPI();
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    public function handleRoute($params)
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        if (isset($params[1])) {
							 | 
						||
| 
								 | 
							
								            //grap appropriate api class based on request params
							 | 
						||
| 
								 | 
							
								            switch ($params[1]) {
							 | 
						||
| 
								 | 
							
								                case "tapes":
							 | 
						||
| 
								 | 
							
								                    //run the request
							 | 
						||
| 
								 | 
							
								                    return $this->tapes->handleRequest($params);
							 | 
						||
| 
								 | 
							
								                    break;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								                default:
							 | 
						||
| 
								 | 
							
								                    break;
							 | 
						||
| 
								 | 
							
								            }
							 | 
						||
| 
								 | 
							
								        } else {
							 | 
						||
| 
								 | 
							
								            return json_encode([
							 | 
						||
| 
								 | 
							
								              "message" => "NO API Identifier provided",
							 | 
						||
| 
								 | 
							
								              "type" => "ERROR",
							 | 
						||
| 
								 | 
							
								            ]);
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |