29 lines
659 B
PHP
29 lines
659 B
PHP
<?php
|
|
|
|
namespace RomhackPlaza;
|
|
|
|
class Format {
|
|
|
|
private function __construct(){}
|
|
|
|
public static function format_for_select2( array $elem_array, string $id_name, string $text_name ) : array {
|
|
|
|
$formatted_array = [];
|
|
|
|
foreach ($elem_array as $elem) {
|
|
if( property_exists( $elem, $id_name ) ) {
|
|
$formatted_array[] = ['id' => $elem->{$id_name}, 'text' => $elem->{$text_name} ?? "None" ];
|
|
}
|
|
}
|
|
|
|
return $formatted_array;
|
|
|
|
}
|
|
|
|
public static function format_nonce_name( string $action ){
|
|
|
|
return 'romhackplaza_' . $_ENV['ROMHACKPLAZA_NONCE_KEY'] . '_' . $action;
|
|
|
|
}
|
|
|
|
} |