Skip to content

Commit

Permalink
add custom action prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanLuLyf committed Oct 24, 2022
1 parent 8c81cc7 commit d673d66
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions BunnyPHP/BunnyPHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class BunnyPHP
private array $variable = [];
private array $container = [];
private array $path = [];
private string $ac = 'ac_';

public function __construct(int $m = BunnyPHP::MODE_NORMAL)
{
Expand Down Expand Up @@ -156,10 +157,11 @@ private function dispatch($controller, $action, $requestMethod)
}
$instance = $class->newInstanceArgs($this->inject($constructor, $paramContext, true, $paramRequired));
$method = null;
if ($class->hasMethod("ac_{$action}_{$requestMethod}")) {
$method = $class->getMethod("ac_{$action}_{$requestMethod}");
} else if ($class->hasMethod("ac_{$action}")) {
$method = $class->getMethod("ac_{$action}");
$ac = $this->ac . $action;
if ($class->hasMethod("{$ac}_{$requestMethod}")) {
$method = $class->getMethod("{$ac}_{$requestMethod}");
} else if ($class->hasMethod($ac)) {
$method = $class->getMethod($ac);
} else if ($class->hasMethod('other')) {
$method = $class->getMethod('other');
}
Expand Down Expand Up @@ -413,6 +415,7 @@ private function initContext()
define('TP_SITE_NAME', $conf->get('site_name', 'BunnyPHP'));
define('TP_SITE_URL', $conf->get('site_url', 'localhost'));
define('TP_SITE_REWRITE', $conf->get('site_rewrite', true));
$this->ac = $conf->get('action_prefix', 'ac_');

if (!defined('TP_NAMESPACE')) define('TP_NAMESPACE', $conf->get('namespace', ''));

Expand Down

0 comments on commit d673d66

Please sign in to comment.