| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package FirePlugins Framework |
| 4 |
* @version 1.0.0 |
| 5 |
* |
| 6 |
* @author FirePlugins <[email protected]> |
| 7 |
* @link https://www.fireplugins.com |
| 8 |
* @copyright Copyright © 2021 FirePlugins All Rights Reserved |
| 9 |
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace FPFramework\Helpers\DataProviders; |
| 13 |
|
| 14 |
if (!defined('ABSPATH')) |
| 15 |
{ |
| 16 |
exit; // Exit if accessed directly. |
| 17 |
} |
| 18 |
|
| 19 |
use FPFramework\Base\Interfaces\GetSelectedItems; |
| 20 |
|
| 21 |
class DevicesProvider implements GetSelectedItems |
| 22 |
{ |
| 23 |
/** |
| 24 |
* Gets items from the Selected Items IDs |
| 25 |
* |
| 26 |
* @param array $items |
| 27 |
* |
| 28 |
* @return array |
| 29 |
*/ |
| 30 |
public function getSelectedItems($items) |
| 31 |
{ |
| 32 |
$devices = fpframework()->helper->devices; |
| 33 |
|
| 34 |
$parsed = []; |
| 35 |
|
| 36 |
foreach ($devices::getDevices() as $key => $value) |
| 37 |
{ |
| 38 |
if (in_array($key, $items)) |
| 39 |
{ |
| 40 |
$parsed[] = [ |
| 41 |
'id' => $key, |
| 42 |
'title' => $value |
| 43 |
]; |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
return $parsed; |
| 48 |
} |
| 49 |
} |