Files
kiri-core/Gii/GiiTask.php
T

96 lines
1.2 KiB
PHP
Raw Normal View History

2020-09-08 19:17:40 +08:00
<?php
namespace Gii;
use Exception;
use Snowflake\Snowflake;
/**
* Class GiiModel
* @package Gii
*/
class GiiTask extends GiiBase
{
public $classFileName;
public $tableName;
public $visible;
public $res;
public $fields;
/**
* @return string[]
* @throws Exception
*/
public function generate()
{
$managerName = $this->input->get('name', null);
if (empty($managerName)) {
throw new Exception('文件名称不能为空~');
}
$html = '<?php
namespace App\Async;
use HttpServer\IInterface\Task;
';
2020-09-08 19:20:28 +08:00
$managerName = ucfirst($managerName);
2020-09-08 19:17:40 +08:00
$html .= '
/**
2020-09-08 19:20:28 +08:00
* Class ' . $managerName . '
2020-09-08 19:19:41 +08:00
* @package App\Async
2020-09-08 19:17:40 +08:00
*/
2020-09-08 19:20:28 +08:00
class ' . $managerName . ' implements Task
2020-09-08 19:17:40 +08:00
{
protected $params = [];
/**
* @return mixed|void
*/
public function onHandler()
{
// TODO: Implement handler() method.
}
/**
* @param $params
* @return $this
*/
public function setParams(array $params)
{
$this->params = $params;
return $this;
}
/**
* @return array
*/
public function getParams()
{
return $this->params;
}
}';
$file = APP_PATH . '/app/Async/' . $managerName . '.php';
if (file_exists($file)) {
unlink($file);
}
Snowflake::writeFile($file, $html);
return [$managerName . '.php'];
}
}