コード例 #1
0
ファイル: Widget.php プロジェクト: renatomartins/cognosys
 /**
  * Runs the widget subclass and renders the view's content
  * @final
  * @return string
  */
 public final function render()
 {
     $this->run();
     $this->_view->setVariables(get_object_vars($this));
     $this->_view->render();
     return $this->_view->content();
 }
コード例 #2
0
ファイル: UserError.php プロジェクト: renatomartins/cognosys
 public function handle($request, $response, $template)
 {
     $view = new View($request, $response);
     $view->setDecorator($template);
     $view->setText($this->message);
     $view->render();
     $view->show();
 }
コード例 #3
0
    public function handle($request, $response, $template)
    {
        $now = new DateTime();
        $time = $now->format(DateTime::RFC850);
        $trace = TextUtil::tabify($this->getTraceAsString(), 1);
        $request = $request ? TextUtil::tabify($request, 1) : '(No request information)';
        $response = $response ? TextUtil::tabify($response, 1) : '(No response information)';
        $view = new View($request, $response);
        $view->setDecorator($template);
        $this->message = <<<EOT
{$this->message}

* Time: {$time}
* File: {$this->file}
* Line: {$this->line}
* Trace:
\t{$trace}

* Request:
\t{$request}

* Response:
\t{$response}
EOT;
        if (Config::get('development')) {
            $this->message = "<pre>{$this->message}</pre>";
            $view->setText($this->message);
        } else {
            Mail::send(Config::get('developers'), 'Application error', $this->message, Mail::PRIORITY_HIGH);
            $view->setText('An email has been sent to the developers to resolve the issue.' . ' Thank you.');
        }
        $view->render();
        $view->show();
    }
コード例 #4
0
ファイル: Controller.php プロジェクト: renatomartins/cognosys
 /**
  * Creates a controller instance
  * @static
  * @final
  * @param Cognosys\Request $request
  * @param Cognosys\Response $response
  * @param array $database_params
  * @param Cognosys\Templates\Decorator
  * @return Cognosys\Controller
  * @throws Exceptions\UserError if the controller name is unknown
  */
 public static final function factory(Request $request, Response $response, array $database_params)
 {
     $cog = $response->cog();
     $controller = $response->controller();
     $action = $response->action();
     $params = $response->params();
     $session = Session::instance();
     if ($cog === null) {
         throw new UserError("There is no such area: <em>{$response->originalController()}</em>");
     }
     // use the namespace inside the application
     $controller_class = "App\\Cogs\\{$cog}\\Controllers\\{$controller}";
     // renders the view even if there is no action
     $instance = new $controller_class($database_params);
     $instance->_request = $request;
     $instance->_response = $response;
     $instance->_session = $session;
     $instance->_view = View::forController($request, $response);
     $instance->_user = $instance->repo(User::classname())->find($session->get('user', false));
     $instance->params = $instance->_getPost();
     //LOW: require all models to use in instanceof?
     return $instance;
 }
コード例 #5
0
ファイル: Widget.php プロジェクト: renatomartins/cognosys
 public function __construct($cogname, $widget_dashed, $params = array())
 {
     $this->_view = View::forWidget($cogname, $widget_dashed);
     $this->_params = $params;
 }
コード例 #6
0
ファイル: Controller.php プロジェクト: renatomartins/cognosys
 /**
  * Sets the text to be rendered in the view
  * @final
  * @param string $text
  * @return void
  */
 protected final function renderText($text)
 {
     $this->_view->setText($text);
 }