Beispiel #1
0
 public function testCamelCase()
 {
     $this->assertEquals('camelCase', Text::camelize("camel_case"));
     $this->assertEquals('CamelCase', Text::ucamelize("camel_case"));
     $this->assertEquals('camelCaseJoe', Text::camelize("camel_case_joe"));
     $this->assertEquals('CamelCaseJoe', Text::ucamelize("camel_case_joe"));
     $this->assertEquals('camelCase', Text::camelize("camel.case", "."));
     $this->assertEquals('CamelCase', Text::ucamelize("camel.case", "."));
     $this->assertEquals('camelCaseJoe', Text::camelize("camel.case.joe", "."));
     $this->assertEquals('CamelCaseJoe', Text::ucamelize("camel.case.joe", "."));
     $this->assertEquals('camelCaseJoe', Text::camelize("camel.case_joe", array(".", "_")));
     $this->assertEquals('CamelCaseJoe', Text::ucamelize("camel_case.joe", array(".", "_")));
 }
Beispiel #2
0
 public function executeControllerAction($action, $params)
 {
     $name = $this->getName();
     $path = Text::camelize($action);
     $return = null;
     $invokeParameters = [];
     if ($methodDetails = $this->getMethod($path)) {
         panie\InjectionContainer::bind(controllers\ModelBinderInterface::class)->to($methodDetails['binder']);
         $method = new \ReflectionMethod($this, $methodDetails['name']);
         honam\TemplateEngine::prependPath("views/{$name}");
         if (View::getTemplate() == null) {
             View::setTemplate("{$name}_{$action}" . '.tpl.php');
         }
         $methodParameters = $method->getParameters();
         foreach ($methodParameters as $methodParameter) {
             $this->bindParameter($invokeParameters, $methodParameter, $params);
         }
         $method->invokeArgs($this, $invokeParameters);
         $return = View::out();
         echo $return;
         return;
     } else {
         foreach ($this->loadedComponents as $component) {
             //@todo Look at how to prevent this from running several times
             if ($component->hasMethod($path)) {
                 $component->executeControllerAction($path, $params);
                 return;
             }
         }
     }
     throw new exceptions\ControllerActionNotFoundException($this, $path);
 }