1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: namespace Xoops\Core\Lists;
13:
14: use Xoops\Form\OptionElement;
15:
16: /**
17: * ListAbstract - return a list of something
18: *
19: * @category Xoops\Core\Lists\ListAbstract
20: * @package Xoops\Core
21: * @author Richard Griffith <richard@geekwright.com>
22: * @copyright 2015 XOOPS Project (http://xoops.org)/
23: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
24: * @link http://xoops.org
25: */
26: abstract class ListAbstract
27: {
28: /**
29: * return a list as an array
30: *
31: * @return array
32: */
33: public static function getList()
34: {
35: return array();
36: }
37:
38: /**
39: * add list to a Xoops\Form\OptionElement
40: *
41: * @param OptionElement $element
42: *
43: * @return void
44: */
45: public static function setOptionsArray(OptionElement $element)
46: {
47: $args = func_get_args();
48: array_shift($args);
49: if (empty($args)) {
50: $element->addOptionArray(static::getList());
51: } else {
52: $element->addOptionArray(call_user_func_array('static::getList', $args));
53: }
54: }
55: }
56: