Skip to content

Commit

Permalink
1. update web/app behavior
Browse files Browse the repository at this point in the history
2. update example
  • Loading branch information
scarwu committed Aug 25, 2018
1 parent ef4f881 commit cce5039
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
4 changes: 2 additions & 2 deletions example/CLI/tasks/ParseTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

class ParseTask extends Task
{
public function run($params = null)
public function run($params = [])
{
if (null !== $params) {
if (0 !== count($params)) {
$this->io->debug('Params:');
var_dump($params);
}
Expand Down
29 changes: 16 additions & 13 deletions example/Web/controllers/MainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,27 @@ public function down()
/**
* Actions
*/
public function defaultAction()
public function defaultAction($params = [])
{
$this->view->setContentPath('main/default');
$this->view->setData([
'title' => 'Oni - A Lightweight PHP Framework for Web & CLI',
'data' => [
'method' => $this->req->method(),
'protocol' => $this->req->protocol(),
'scheme' => $this->req->scheme(),
'host' => $this->req->host(),
'uri' => $this->req->uri(),
'isAjax' => $this->req->isAjax(),
'contentLength' => $this->req->contentLength(),
'contentType' => $this->req->contentType(),
'body' => $this->req->body(),
'query' => $this->req->query(),
'content' => $this->req->content(),
'file' => $this->req->file(),
'params' => $params,
'request' => [
'method' => $this->req->method(),
'protocol' => $this->req->protocol(),
'scheme' => $this->req->scheme(),
'host' => $this->req->host(),
'uri' => $this->req->uri(),
'isAjax' => $this->req->isAjax(),
'contentLength' => $this->req->contentLength(),
'contentType' => $this->req->contentType(),
'body' => $this->req->body(),
'query' => $this->req->query(),
'content' => $this->req->content(),
'file' => $this->req->file(),
],
'native' => [
'server' => $_SERVER,
'post' => $_POST,
Expand Down
6 changes: 3 additions & 3 deletions src/Oni/Web/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ private function loadController()
}

// Rewrite Controller
$action = null;

if (false === file_exists("{$path}Controller.php")) {
$namespace = $this->getAttr('controller/namespace');
$path = $this->getAttr('controller/path');
$handler = ucfirst($this->getAttr('controller/default/handler'));
$action = $this->getAttr('controller/default/action') . 'Action';

if (false === file_exists("{$path}/{$handler}Controller.php")) {
$handler = ucfirst($this->getAttr('controller/error/handler'));
Expand All @@ -219,10 +219,10 @@ private function loadController()
}
}

$namespace = $this->getAttr('controller/namespace');
$namespace = "{$namespace}\\{$handler}Controller";
} else {
$namespace = "{$namespace}Controller";
$action = null;
}

// Set View Attrs
Expand Down

0 comments on commit cce5039

Please sign in to comment.