예제 #1
0
 public function test01()
 {
     ### contains($needles, $haystack)
     $this->assertTrue(Util::string_has('this exists', 'Testing to see if this exists.'));
     $this->assertFalse(Util::string_has('this does not exist', 'Testing to see if this exists.'));
     ### slug_to_title($slug)
     $this->assertEquals('Imagine That This Is A Slug', Util::slug_to_title('imagine-that-this-is-a-slug'));
     ### remove_namespace($class_name, $class_suffix = NULL)
     $this->assertEquals('Routing', Util::remove_namespace(\Og\Routing::class));
     $this->assertEquals('Routing', Util::remove_namespace(\Og\Routing::class, 'Og'));
     ### name_from_class($class_name, $suffix_to_remove = 'HttpController')
     $this->assertEquals('applicationcontroller', Util::alias_from_class('Og\\ApplicationController', ''));
     $this->assertEquals('application', Util::alias_from_class('Og\\ApplicationController', 'Controller'));
     $this->assertEquals('application', Util::alias_from_class('Og\\ApplicationController'));
 }
예제 #2
0
 /**
  * Execute an HTTP route.
  *
  * @param          $input  - HTTP input fields
  * @param          $action - Route action
  *
  * @return mixed|Response
  */
 public function executeRouteAction($input, $action)
 {
     // register the current Input object
     $this->forge->add(['input', Input::class], new Input($input));
     $this->before_route_dispatch();
     // If the route is a controller::method then first determine if the controller
     // implements __invoke(). We'll assume the signature is correct for Middleware.
     if (is_string($action) and Util::string_has(static::ROUTE_METHOD_SEPARATOR, $action)) {
         // extract controller and method
         list($controller, $method) = explode(static::ROUTE_METHOD_SEPARATOR, $action);
         // use the static::APP_NAMESPACE to normalize constructor names without namespace.
         $controller = $this->normalize_namespace($controller);
         // depending on the controller constructor signature,
         // find and instantiate the constructor
         $processor = $this->newConstructorWithInjection($controller);
         // transfer control over to the controller
         $result = $this->invoke_controller($processor, $method);
     } else {
         // Otherwise, transfer control to the controller::method directly.
         // Note that call() handles dependency injection.
         $result = $this->forge->callWithDependencyInjection($action);
     }
     $this->after_route_dispatch();
     return $result;
 }
예제 #3
0
 /**
  * Register an event listener with the dispatcher.
  *
  * @param  string|array $events
  * @param  mixed        $listener
  * @param  int          $priority
  *
  * @return void
  */
 function listen($events, $listener, $priority = 0)
 {
     foreach ((array) $events as $event) {
         if (Util::string_has('*', $event)) {
             $this->setup_wildcard_listen($event, $listener);
         } else {
             $this->listeners[$event][$priority][] = $this->make($listener);
             unset($this->sorted[$event]);
         }
     }
 }
예제 #4
0
 public function test_02_BladeView_layout()
 {
     $html = $this->view->render('pages.home', ['contents' => 'This was passed at render time.']);
     $this->assertTrue(Util::string_has('<div class="container">', $html));
     $this->assertTrue(Util::string_has('This was passed at render time', $html));
 }