-
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.
Add event constants and change email address.
- Loading branch information
Showing
18 changed files
with
44 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
@@ -27,6 +27,11 @@ class Form | |
public static array $config = []; | ||
private static string $form; | ||
|
||
public const | ||
EVENT_RENDER = 'render', | ||
EVENT_REQUEST = 'request', | ||
EVENT_RESPONSE = 'response'; | ||
|
||
public const | ||
TYPE_PASSWORD = 'password', | ||
TYPE_MONEY = 'money', | ||
|
@@ -108,15 +113,15 @@ public static function field(string $key): FormField | |
* Form page render | ||
* | ||
* @param string $table | ||
* @param null|callable $middleware function(string $action, array &$data){} | ||
* @param null|callable $callback function(string $event, array &$data){} | ||
* @throws Exception | ||
* @throws ErrorException | ||
* @throws InvalidArgumentException | ||
* @throws InvalidArgumentException | ||
* @throws GlobalInvalidArgumentException | ||
* @throws PDOException | ||
*/ | ||
public static function render(string $table, ?callable $middleware = null) | ||
public static function render(string $table, ?callable $callback = null) | ||
{ | ||
$_id = Request::request('_id', 0); | ||
$_form = Request::request('_form', ''); | ||
|
@@ -158,16 +163,16 @@ public static function render(string $table, ?callable $middleware = null) | |
'field' => $field, | ||
]; | ||
|
||
if (is_callable($middleware)) { | ||
$middleware('render', $renderData); | ||
if (is_callable($callback)) { | ||
$callback(self::EVENT_RENDER, $renderData); | ||
} | ||
|
||
Response::render(Admin::path() . '/src/Admin/View.phtml', ['title' => $_title, 'script' => Admin::globalScript('Form', $renderData)]); | ||
} else { | ||
$sqlData = self::dataFilter($field, Request::request()); | ||
|
||
if (is_callable($middleware)) { | ||
$middleware('request', $sqlData); | ||
if (is_callable($callback)) { | ||
$callback(self::EVENT_REQUEST, $sqlData); | ||
} | ||
|
||
$rsId = 0; | ||
|
@@ -190,8 +195,8 @@ public static function render(string $table, ?callable $middleware = null) | |
if ($rsId || $rsIds) { | ||
Model::userLog($userId, true); | ||
|
||
if (is_callable($middleware)) { | ||
$middleware('response', $resData); | ||
if (is_callable($callback)) { | ||
$callback(self::EVENT_RESPONSE, $resData); | ||
} | ||
} | ||
|
||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
@@ -28,6 +28,11 @@ class Table | |
public static array $config = []; | ||
private static int $buttonIndex = 0; | ||
|
||
public const | ||
EVENT_RENDER = 'render', | ||
EVENT_REQUEST = 'request', | ||
EVENT_RESPONSE = 'response'; | ||
|
||
public const | ||
ACTION_FORM = 'form', | ||
ACTION_PAGE = 'page', | ||
|
@@ -153,15 +158,15 @@ public static function statistic(string $key): TableStatistic | |
* Table page render | ||
* | ||
* @param string $table | ||
* @param null|callable $middleware function(string $action, array &$data){} | ||
* @param null|callable $callback function(string $event, array &$data){} | ||
* @throws Exception | ||
* @throws ErrorException | ||
* @throws InvalidArgumentException | ||
* @throws InvalidArgumentException | ||
* @throws GlobalInvalidArgumentException | ||
* @throws PDOException | ||
*/ | ||
public static function render(string $table, ?callable $middleware = null) | ||
public static function render(string $table, ?callable $callback = null) | ||
{ | ||
$userId = Auth::getUserId(); | ||
$userInfo = Model::getUserInfo($userId); | ||
|
@@ -256,8 +261,8 @@ public static function render(string $table, ?callable $middleware = null) | |
'statistic' => Table::$config['statistic'] ?? [], | ||
]; | ||
|
||
if (is_callable($middleware)) { | ||
$middleware('render', $renderData); | ||
if (is_callable($callback)) { | ||
$callback(self::EVENT_RENDER, $renderData); | ||
} | ||
|
||
Model::userLog($userId); | ||
|
@@ -290,8 +295,8 @@ public static function render(string $table, ?callable $middleware = null) | |
|
||
$searchData = self::searchFilter($column, Request::request()); | ||
|
||
if (is_callable($middleware)) { | ||
$middleware('request', $searchData); | ||
if (is_callable($callback)) { | ||
$callback(self::EVENT_REQUEST, $searchData); | ||
} | ||
|
||
$count = Model::tableCount($table, $searchData); | ||
|
@@ -302,8 +307,8 @@ public static function render(string $table, ?callable $middleware = null) | |
'list' => $list, | ||
]; | ||
|
||
if (is_callable($middleware)) { | ||
$middleware('response', $resData); | ||
if (is_callable($callback)) { | ||
$callback(self::EVENT_RESPONSE, $resData); | ||
} | ||
|
||
Response::api(0, null, $resData); | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
/* | ||
* This file is part of the Alight package. | ||
* | ||
* (c) June So <[email protected]> | ||
* (c) June So <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|