[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10 namespace Joomla\CMS\Form\Rule; 11 12 use Joomla\CMS\Form\Form; 13 use Joomla\CMS\Form\FormRule; 14 use Joomla\Registry\Registry; 15 16 // phpcs:disable PSR1.Files.SideEffects 17 \defined('JPATH_PLATFORM') or die; 18 // phpcs:enable PSR1.Files.SideEffects 19 20 /** 21 * Form Rule class for the Joomla Platform. 22 * 23 * @since 1.7.0 24 */ 25 class NotequalsRule extends FormRule 26 { 27 /** 28 * Method to test if two values are not equal. To use this rule, the form 29 * XML needs a validate attribute of equals and a field attribute 30 * that is equal to the field to test against. 31 * 32 * @param \SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object. 33 * @param mixed $value The form field value to validate. 34 * @param string $group The field name group control value. This acts as an array container for the field. 35 * For example if the field has name="foo" and the group value is set to "bar" then the 36 * full field name would end up being "bar[foo]". 37 * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. 38 * @param Form $form The form object for which the field is being tested. 39 * 40 * @return boolean True if the value is valid, false otherwise. 41 * 42 * @since 1.7.0 43 * @throws \InvalidArgumentException 44 * @throws \UnexpectedValueException 45 */ 46 public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) 47 { 48 $field = (string) $element['field']; 49 50 // Check that a validation field is set. 51 if (!$field) { 52 throw new \UnexpectedValueException(sprintf('$field empty in %s::test', \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 two values against each other. 60 if ($value != $input->get($field)) { 61 return true; 62 } 63 64 return false; 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 |