[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_modules 6 * 7 * @copyright (C) 2015 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Modules\Administrator\Field; 12 13 use Joomla\CMS\Form\Field\ListField; 14 use Joomla\Component\Modules\Administrator\Helper\ModulesHelper; 15 16 // phpcs:disable PSR1.Files.SideEffects 17 \defined('_JEXEC') or die; 18 // phpcs:enable PSR1.Files.SideEffects 19 20 /** 21 * Modules Module field. 22 * 23 * @since 3.4.2 24 */ 25 class ModulesModuleField extends ListField 26 { 27 /** 28 * The form field type. 29 * 30 * @var string 31 * @since 3.4.2 32 */ 33 protected $type = 'ModulesModule'; 34 35 /** 36 * Client name. 37 * 38 * @var string 39 * @since 4.0.0 40 */ 41 protected $client; 42 43 /** 44 * Method to get certain otherwise inaccessible properties from the form field object. 45 * 46 * @param string $name The property name for which to get the value. 47 * 48 * @return mixed The property value or null. 49 * 50 * @since 4.0.0 51 */ 52 public function __get($name) 53 { 54 switch ($name) { 55 case 'client': 56 return $this->$name; 57 } 58 59 return parent::__get($name); 60 } 61 62 /** 63 * Method to set certain otherwise inaccessible properties of the form field object. 64 * 65 * @param string $name The property name for which to set the value. 66 * @param mixed $value The value of the property. 67 * 68 * @return void 69 * 70 * @since 4.0.0 71 */ 72 public function __set($name, $value) 73 { 74 switch ($name) { 75 case 'client': 76 $this->$name = (string) $value; 77 break; 78 79 default: 80 parent::__set($name, $value); 81 } 82 } 83 84 /** 85 * Method to attach a Form object to the field. 86 * 87 * @param \SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object. 88 * @param mixed $value The form field value to validate. 89 * @param string $group The field name group control value. This acts as an array container for the field. 90 * For example if the field has name="foo" and the group value is set to "bar" then the 91 * full field name would end up being "bar[foo]". 92 * 93 * @return boolean True on success. 94 * 95 * @see FormField::setup() 96 * @since 4.0.0 97 */ 98 public function setup(\SimpleXMLElement $element, $value, $group = null) 99 { 100 $result = parent::setup($element, $value, $group); 101 102 if ($result === true) { 103 $this->client = $this->element['client'] ? (string) $this->element['client'] : 'site'; 104 } 105 106 return $result; 107 } 108 109 /** 110 * Method to get the field options. 111 * 112 * @return array The field option objects. 113 * 114 * @since 3.4.2 115 */ 116 public function getOptions() 117 { 118 $clientId = $this->client === 'administrator' ? 1 : 0; 119 $options = ModulesHelper::getModules($clientId); 120 121 return array_merge(parent::getOptions(), $options); 122 } 123 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |