| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\App\Http\Controllers; |
| 4 |
|
| 5 |
use FluentCart\App\Helpers\Helper; |
| 6 |
use FluentCart\App\Models\User; |
| 7 |
use FluentCart\App\Services\RoleManager; |
| 8 |
use FluentCart\Framework\Http\Controller as BaseController; |
| 9 |
|
| 10 |
abstract class Controller extends BaseController |
| 11 |
{ |
| 12 |
/** |
| 13 |
* |
| 14 |
* @param string $permission |
| 15 |
* @return false|string|void |
| 16 |
*/ |
| 17 |
public function redirectOnUnauthorized(string $permission) |
| 18 |
{ |
| 19 |
return true; |
| 20 |
} |
| 21 |
|
| 22 |
public function getUser() |
| 23 |
{ |
| 24 |
return Helper::getCurrentUser(); |
| 25 |
} |
| 26 |
|
| 27 |
public function entityNotFoundError($message, $buttonText = null, $route = '/'): \WP_REST_Response |
| 28 |
{ |
| 29 |
return $this->sendError([ |
| 30 |
'data' => [ |
| 31 |
'message' => $message, |
| 32 |
'buttonText' => $buttonText ?? __('Back to Dashboard', 'fluent-cart'), |
| 33 |
'route' => $route, |
| 34 |
], |
| 35 |
'code' => 'fluent_cart_entity_not_found', |
| 36 |
], 404); |
| 37 |
} |
| 38 |
|
| 39 |
} |
| 40 |
|