add:新增表单生成

This commit is contained in:
JaguarJack
2021-03-14 07:42:01 +08:00
parent 822ff3874a
commit b4a1e9bc4e
6 changed files with 460 additions and 3 deletions

View File

@@ -0,0 +1,34 @@
<?php
namespace catcher\library\form;
use catcher\exceptions\FailedException;
abstract class FormFactory
{
abstract public static function from();
/**
* 创建 Form
*
* @time 2021年03月02日
* @param $name
* @return mixed
*/
public static function create($name)
{
$form = static::from() . '\\'. ucfirst($name);
if (!class_exists($form)) {
throw new FailedException(sprintf('Form [%s] not found! Please create it first', ucfirst($name)));
}
$form = app($form);
if (!$form instanceof Form) {
throw new FailedException(sprintf('Form [%s] must implements interface [FormCreate]', ucfirst($name)));
}
return $form->create();
}
}