[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Site 5 * @subpackage com_users 6 * 7 * @copyright (C) 2017 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\Users\Site\Rule; 12 13 use Joomla\CMS\Form\Form; 14 use Joomla\CMS\Form\FormRule; 15 use Joomla\Registry\Registry; 16 17 // phpcs:disable PSR1.Files.SideEffects 18 \defined('JPATH_PLATFORM') or die; 19 // phpcs:enable PSR1.Files.SideEffects 20 21 /** 22 * FormRule for com_users to be sure only one redirect logout field has a value 23 * 24 * @since 3.6 25 */ 26 class LogoutUniqueFieldRule extends FormRule 27 { 28 /** 29 * Method to test if two fields have a value in order to use only one field. 30 * To use this rule, the form 31 * XML needs a validate attribute of logoutuniquefield and a field attribute 32 * that is equal to the field to test against. 33 * 34 * @param \SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object. 35 * @param mixed $value The form field value to validate. 36 * @param string $group The field name group control value. This acts as an array container for the field. 37 * For example if the field has name="foo" and the group value is set to "bar" then the 38 * full field name would end up being "bar[foo]". 39 * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. 40 * @param Form $form The form object for which the field is being tested. 41 * 42 * @return boolean True if the value is valid, false otherwise. 43 * 44 * @since 3.6 45 */ 46 public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) 47 { 48 $logoutRedirectUrl = $input['params']->logout_redirect_url; 49 $logoutRedirectMenuitem = $input['params']->logout_redirect_menuitem; 50 51 if ($form === null) { 52 throw new \InvalidArgumentException(sprintf('The value for $form must not be null in %s', get_class($this))); 53 } 54 55 if ($input === null) { 56 throw new \InvalidArgumentException(sprintf('The value for $input must not be null in %s', get_class($this))); 57 } 58 59 // Test the input values for logout. 60 if ($logoutRedirectUrl != '' && $logoutRedirectMenuitem != '') { 61 return false; 62 } 63 64 return true; 65 } 66 }
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 |