mirror of
https://github.com/Mibew/mibew-operator-status-plugin.git
synced 2025-01-22 10:00:30 +03:00
correct to use unified style for the route
This commit is contained in:
parent
6dd2f86e99
commit
ceac3f24ec
@ -3,7 +3,7 @@ Plugin for Mibew, get statement based on the availability of operators.
|
||||
|
||||
# Useage
|
||||
|
||||
Request `<MIBEW-BASE-URL>/opstatus?code=<OPERATOR-CODE>`, your will get `true` when operator
|
||||
Request `<MIBEW-BASE-URL>/opstatus/<OPERATOR-CODE>`, your will get `true` when operator
|
||||
is online or `false` when operator is offline.
|
||||
|
||||
# Install
|
||||
|
@ -42,21 +42,23 @@ class OperatorStatusController extends AbstractController
|
||||
*/
|
||||
public function indexAction(Request $request)
|
||||
{
|
||||
$is_online = "false";
|
||||
|
||||
$opcode = $request->query->get('code', false);
|
||||
$online_operators = get_online_operators();
|
||||
if (count($online_operators) > 0) {
|
||||
if (empty($opcode)) {
|
||||
$is_online = "true";
|
||||
} else {
|
||||
|
||||
$opcode = $request->attributes->get('opcode');
|
||||
$online_operators = get_online_operators();
|
||||
|
||||
if ( count($online_operators) == 0 ) {
|
||||
$is_online = "false";
|
||||
} else if ( !empty($opcode) ) {
|
||||
$is_online = "false";
|
||||
foreach ($online_operators as $item) {
|
||||
if ($item['code'] == $opcode) {
|
||||
$is_online = "true";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$response = new Response($is_online);
|
||||
$response->headers->set('Access-Control-Allow-Origin', '*');
|
||||
return $response;
|
||||
|
@ -1,4 +1,4 @@
|
||||
mibew_boilerplate_hello:
|
||||
path: /opstatus
|
||||
path: /opstatus/{opcode}
|
||||
defaults:
|
||||
_controller: Everyx\Mibew\Plugin\OperatorStatus\Controller\OperatorStatusController::indexAction
|
||||
|
Loading…
Reference in New Issue
Block a user