Ejemplo n.º 1
0
 public function getBody()
 {
     $viewName = $this->getViewName();
     if ($this->body === null && $viewName !== null) {
         $attributes = $this->getAttributes();
         $body = $this->viewManager->render($viewName, $attributes);
         $this->setBody($body);
     }
     return $this->body;
 }
Ejemplo n.º 2
0
 public function bind($value)
 {
     if (is_callable($value)) {
         $value = $this->injector->invoke($value);
     }
     if ($value === null) {
         throw new \Exception("Value cannot be null");
     } else {
         if ($value instanceof Route) {
             $this->router->setRoute($value);
         } else {
             if ($value instanceof Command) {
                 $this->consoleManager->addCommand($value);
             } else {
                 if ($value instanceof Event) {
                     $this->eventManager->addEvent($value);
                 } else {
                     if ($value instanceof View) {
                         $this->viewManager->setView($value);
                     } else {
                         if ($value instanceof Renderer) {
                             $this->viewManager->setRenderer($value);
                         } else {
                             if ($value instanceof Dependency) {
                                 $this->injector->setDependency($value->getValue(), $value->getName());
                             } else {
                                 $type = gettype($value);
                                 if (is_object($value)) {
                                     $type = get_class($value);
                                 }
                                 throw new \Exception("Cannot bind value with type {$type}");
                             }
                         }
                     }
                 }
             }
         }
     }
 }