-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from zunnu/dev
Rest api
- Loading branch information
Showing
7 changed files
with
108 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace LogReader\Controller\Api\V1; | ||
|
||
use App\Controller\AppController as BaseController; | ||
|
||
class AppController extends BaseController | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
namespace LogReader\Controller\Api\V1; | ||
|
||
use LogReader\Controller\Api\V1\AppController; | ||
use Cake\Log\Log; | ||
use LogReader\Reader; | ||
|
||
class LogReaderController extends AppController | ||
{ | ||
public function initialize() { | ||
parent::initialize(); | ||
} | ||
|
||
/** | ||
* Logs method | ||
*/ | ||
public function logs($date = null) { | ||
$this->viewBuilder()->setLayout(false); | ||
$conditions = []; | ||
|
||
// SEARCH | ||
if ($this->request->is('post')) { | ||
$data = $this->request->getData(); | ||
|
||
if(!empty($data['files'])) { | ||
$files = explode(',', $data['files']); | ||
$conditions['files'] = array_map('trim', array_filter($files)); | ||
} | ||
|
||
if(!empty($data['types'])) { | ||
$types = explode(',', $data['types']); | ||
$conditions['types'] = array_map('trim', array_filter($types)); | ||
} | ||
} | ||
|
||
$this->Reader = new Reader($conditions); | ||
$logs = $this->Reader->read(); | ||
|
||
$this->set([ | ||
'logs' => $logs, | ||
'_serialize' => ['logs'] | ||
]); | ||
} | ||
|
||
/** | ||
* Types method | ||
* Return available log types | ||
*/ | ||
public function types($date = null) { | ||
$this->viewBuilder()->setLayout(false); | ||
$this->Reader = new Reader(); | ||
$types = $this->Reader->getLogTypes(); | ||
|
||
$this->set([ | ||
'types' => $types, | ||
'_serialize' => ['types'] | ||
]); | ||
} | ||
|
||
/** | ||
* Files method | ||
* Return the available log files | ||
*/ | ||
public function files($date = null) { | ||
$this->viewBuilder()->setLayout(false); | ||
$this->Reader = new Reader(); | ||
$files = $this->Reader->getFiles(); | ||
|
||
$this->set([ | ||
'files' => $files, | ||
'_serialize' => ['files'] | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters