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
|
# 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.
|
is online or `false` when operator is offline.
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
|
@ -42,21 +42,23 @@ class OperatorStatusController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
public function indexAction(Request $request)
|
public function indexAction(Request $request)
|
||||||
{
|
{
|
||||||
$is_online = "false";
|
$is_online = "true";
|
||||||
|
|
||||||
$opcode = $request->query->get('code', false);
|
$opcode = $request->attributes->get('opcode');
|
||||||
$online_operators = get_online_operators();
|
$online_operators = get_online_operators();
|
||||||
if (count($online_operators) > 0) {
|
|
||||||
if (empty($opcode)) {
|
if ( count($online_operators) == 0 ) {
|
||||||
$is_online = "true";
|
$is_online = "false";
|
||||||
} else {
|
} else if ( !empty($opcode) ) {
|
||||||
foreach ($online_operators as $item) {
|
$is_online = "false";
|
||||||
if ($item['code'] == $opcode) {
|
foreach ($online_operators as $item) {
|
||||||
$is_online = "true";
|
if ($item['code'] == $opcode) {
|
||||||
}
|
$is_online = "true";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = new Response($is_online);
|
$response = new Response($is_online);
|
||||||
$response->headers->set('Access-Control-Allow-Origin', '*');
|
$response->headers->set('Access-Control-Allow-Origin', '*');
|
||||||
return $response;
|
return $response;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
mibew_boilerplate_hello:
|
mibew_boilerplate_hello:
|
||||||
path: /opstatus
|
path: /opstatus/{opcode}
|
||||||
defaults:
|
defaults:
|
||||||
_controller: Everyx\Mibew\Plugin\OperatorStatus\Controller\OperatorStatusController::indexAction
|
_controller: Everyx\Mibew\Plugin\OperatorStatus\Controller\OperatorStatusController::indexAction
|
||||||
|
Loading…
Reference in New Issue
Block a user