|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * Copyright (C) 2024 Deciso B.V. |
| 5 | + * Copyright (C) 2024 github.com/mr-manuel |
| 6 | + * All rights reserved. |
| 7 | + * |
| 8 | + * Redistribution and use in source and binary forms, with or without |
| 9 | + * modification, are permitted provided that the following conditions are met: |
| 10 | + * |
| 11 | + * 1. Redistributions of source code must retain the above copyright notice, |
| 12 | + * this list of conditions and the following disclaimer. |
| 13 | + * |
| 14 | + * 2. Redistributions in binary form must reproduce the above copyright |
| 15 | + * notice, this list of conditions and the following disclaimer in the |
| 16 | + * documentation and/or other materials provided with the distribution. |
| 17 | + * |
| 18 | + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
| 19 | + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
| 20 | + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 21 | + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, |
| 22 | + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 24 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 25 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 26 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 27 | + * POSSIBILITY OF SUCH DAMAGE. |
| 28 | + */ |
| 29 | + |
| 30 | +namespace OPNsense\Opnarplog\FieldTypes; |
| 31 | + |
| 32 | +use OPNsense\Base\FieldTypes\BaseListField; |
| 33 | +use OPNsense\Core\Config; |
| 34 | + |
| 35 | +/** |
| 36 | + * Class OpnarplogDomainField |
| 37 | + * @package OPNsense\Opnarplog\FieldTypes |
| 38 | + * Created from src\opnsense\mvc\app\models\OPNsense\Unbound\FieldTypes\UnboundInterfaceField.php |
| 39 | + */ |
| 40 | +class OpnarplogInterfaceField extends BaseListField |
| 41 | +{ |
| 42 | + /** |
| 43 | + * Iterate over all interfaces in the configuration and only exclude virtual interfaces. |
| 44 | + */ |
| 45 | + public function actionPostLoadingEvent() |
| 46 | + { |
| 47 | + $config = Config::getInstance()->object(); |
| 48 | + |
| 49 | + foreach ($config->interfaces->children() as $key => $node) { |
| 50 | + if (empty($node->virtual)) { |
| 51 | + $this->internalOptionList[str_replace(".", "_", $node->if)] = !empty($node->descr) ? (string)$node->descr : strtoupper($key); |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + natcasesort($this->internalOptionList); |
| 56 | + } |
| 57 | +} |
0 commit comments