CoreFiles by mySites.guru
BeforeDisplayMethods.php56 lines, 1,276 bytes, from Joomla_4.2.0-beta1-Beta-Full_Package.zip
Raw History Compare with 4.1.0-beta3
md5
456681c0c36bcd0be05f6dd5dcd886a4
sha1
35ef962ffd343e6ea9b2536fea1ac2db35a4a88c
sha256
1be9f4694f64a2f8a08a6dcb4c3132458f53dda883599dc4aed2310b9a9fa942
<?php
/**
 * Joomla! Content Management System
 *
 * @copyright  (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE
 */

namespace Joomla\CMS\Event\MultiFactor;

\defined('JPATH_PLATFORM') or die;

use DomainException;
use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\CMS\Event\Result\ResultAware;
use Joomla\CMS\User\User;

/**
 * Concrete Event class for the onUserMultifactorBeforeDisplayMethods event
 *
 * @since 4.2.0
 */
class BeforeDisplayMethods extends AbstractImmutableEvent
{
	use ResultAware;

	/**
	 * Public constructor
	 *
	 * @param   User  $user  The user the MFA methods are displayed for
	 *
	 * @since   4.2.0
	 */
	public function __construct(User $user)
	{
		parent::__construct('onUserMultifactorBeforeDisplayMethods', ['user' => $user]);
	}

	/**
	 * Validate the value of the 'user' named parameter
	 *
	 * @param   User  $value  The value to validate
	 *
	 * @return  User
	 * @since   4.2.0
	 */
	public function setUser(User $value): User
	{
		if (empty($value) || ($value->id <= 0) || ($value->guest == 1))
		{
			throw new DomainException(sprintf('Argument \'user\' of event %s must be a non-guest User object.', $this->name));
		}

		return $value;
	}
}

The same content is in 2 releases, Joomla 4.2.0-beta1 to 4.2.0-beta2. See them all, or every version of this file.