<?php

namespace App\Helpers;

use CodeIgniter\HTTP\IncomingRequest;
use App\Models\MyLogModel;

class MyLogHelper extends CommonHelper
{
    protected ?IncomingRequest $request = null;
    public function __construct(?IncomingRequest $request = null)
    {
        parent::__construct($request);
        $this->setTitleField(MyLogModel::TITLE);
    }

    public function getFieldView(string $field, array $viewDatas, array $extras = []): string
    {
        $value = $viewDatas['entity']->$field;
        switch ($field) {
            case 'content':
                $value = nl2br($value);
                break;
            default:
                $value = parent::getFieldView($field, $viewDatas, $extras);
                break;
        }
        return $value;
    }
    public function getListButton(string $action, array $viewDatas, array $extras = []): string
    {
        switch ($action) {
            case 'create':
                $action = "";
                break;
            case 'modify':
                $action = $viewDatas['cnt'];
                break;
            case 'delete':
                $action = "";
                break;
            case 'batchjob':
                $action = "";
                break;
            case 'batchjob_delete':
                $action = "";
                break;
            default:
                $action = parent::getListButton($action, $viewDatas, $extras);
                break;
        }
        return $action;
    }
}
