Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: admin
- * Date: 19.07.2019
- * Time: 10:28
- */
- namespace app\controller;
- use app\models\Mops;
- use app\models\Siba;
- use app\models\Dachshund;
- use app\models\Labrador;
- use app\models\Rubber;
- class controller
- {
- public $view;
- public function __construct()
- {
- $this->view = new \app\views\View();
- }
- public function action_index(){
- $this->view->generate( 'main_page.php');
- }
- public function action_command()
- {
- $routes = [
- 'mops' => Mops::class,
- 'sibainu' => Siba::class,
- 'dachshund' => Dachshund::class,
- 'labragor' => Labrador::class,
- 'rubber_dog' => Rubber::class
- ];
- $path = explode('/', $_POST['message']);
- if(!empty($path[0])) $nameDog=$path[0];
- if(isset($path[1])) $command=$path[1];
- if(isset($routes[$nameDog])){
- $className = $routes[$nameDog];
- $controller = new $className();
- method_exists($controller, $command)? $controller->$command(): Route::Error();
- }
- }
- public static function Error()
- {
- echo json_encode('Oh, Error');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement