Exemple #1
0
 public function testLocateClassException()
 {
     Environment::mock(array('REQUEST_METHOD' => 'GET'));
     $deal = new Deal();
     $this->setExpectedException('Exception');
     $deal->locateClass('Fake', array(''));
 }
Exemple #2
0
 public function defaultPluralMapper()
 {
     return function ($controllerName) {
         $app = Deal::getInstance();
         $inflector = Inflector::get();
         $className = $inflector->camelize($controllerName);
         // model
         try {
             $modelClass = Deal::locateClass($className, $app->config('app.models.paths'));
             $controllerClass = Deal::locateClass($className, $app->config('app.controllers.paths'));
         } catch (\Exception $e) {
             $app->notFound();
         }
         $connection = $this->getConnection($app->config);
         $model = new $modelClass($connection);
         $controller = new $controllerClass($app, $model);
         $method = strtolower($app->request()->getMethod());
         $result = $controller->{$method}();
         $result = $this->massagePayload($controllerName, $result);
         $app->respond($result);
     };
 }