CoreFiles by mySites.guru
UserFactoryAwareTrait.php61 lines, 1,386 bytes, from Joomla_5.2.3-Stable-Full_Package.zip
Raw History Compare with 5.2.2
md5
006a18fed840ebc23e052b6d16861da0
sha1
60f2dfc5d6eb1c0b1516116190c288f225650e2a
sha256
59d25c8e3b8085bf8597f5d82edaaab0aa9314c9364e05af66f3e4c5e4d64955
<?php

/**
 * Joomla! Content Management System
 *
 * @copyright  (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\User;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Defines the trait for a UserFactoryInterface Aware Class.
 *
 * @since  4.4.0
 */
trait UserFactoryAwareTrait
{
    /**
     * UserFactoryInterface
     *
     * @var    UserFactoryInterface
     * @since  4.4.0
     */
    private $userFactory;

    /**
     * Get the UserFactoryInterface.
     *
     * @return  UserFactoryInterface
     *
     * @since   4.4.0
     * @throws  \UnexpectedValueException May be thrown if the UserFactory has not been set.
     */
    protected function getUserFactory(): UserFactoryInterface
    {
        if ($this->userFactory) {
            return $this->userFactory;
        }

        throw new \UnexpectedValueException('UserFactory not set in ' . __CLASS__);
    }

    /**
     * Set the user factory to use.
     *
     * @param   UserFactoryInterface  $userFactory  The user factory to use.
     *
     * @return  void
     *
     * @since   4.4.0
     */
    public function setUserFactory(UserFactoryInterface $userFactory): void
    {
        $this->userFactory = $userFactory;
    }
}

The same content is in 191 releases, Joomla 4.4.0-alpha1 to 6.2.1-rc1. See them all, or every version of this file.