mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-11 02:36:42 +02:00
refactor(analytics): move all analytics files to a new Libraries/Analytics folder
- add page hit on podcast activity page - update development docs
This commit is contained in:
parent
1c0d6cee44
commit
247ae1824f
59 changed files with 865 additions and 752 deletions
54
app/Libraries/Analytics/Controllers/AnalyticsController.php
Normal file
54
app/Libraries/Analytics/Controllers/AnalyticsController.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace Analytics\Controllers;
|
||||
|
||||
use CodeIgniter\Controller;
|
||||
|
||||
class AnalyticsController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $className;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $methodName;
|
||||
|
||||
public function _remap($method, ...$params)
|
||||
{
|
||||
if (!isset($params[1])) {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
$this->className = model('Analytics' . $params[1] . 'Model');
|
||||
$this->methodName = 'getData' . (empty($params[2]) ? '' : $params[2]);
|
||||
|
||||
return $this->$method(
|
||||
$params[0],
|
||||
isset($params[3]) ? $params[3] : null,
|
||||
);
|
||||
}
|
||||
|
||||
public function getData($podcastId, $episodeId)
|
||||
{
|
||||
$analytics_model = new $this->className();
|
||||
$methodName = $this->methodName;
|
||||
if ($episodeId) {
|
||||
return $this->response->setJSON(
|
||||
$analytics_model->$methodName($podcastId, $episodeId),
|
||||
);
|
||||
} else {
|
||||
return $this->response->setJSON(
|
||||
$analytics_model->$methodName($podcastId),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue