-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a UserFactoryAware interface (#40337)
* Introduce an UserFactoryAware interface * 0 * Test * safe * trigger deprecated message * protected * test * load user correctly * fix the deprecated message
- Loading branch information
Showing
9 changed files
with
232 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?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 | ||
|
||
/** | ||
* Interface to be implemented by classes depending on a user factory. | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
interface UserFactoryAwareInterface | ||
{ | ||
/** | ||
* Set the user factory to use. | ||
* | ||
* @param UserFactoryInterface $factory The user factory to use. | ||
* | ||
* @return void | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function setUserFactory(UserFactoryInterface $factory): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?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 __DEPLOY_VERSION__ | ||
*/ | ||
trait UserFactoryAwareTrait | ||
{ | ||
/** | ||
* UserFactoryInterface | ||
* | ||
* @var UserFactoryInterface | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
private $userFactory; | ||
|
||
/** | ||
* Get the UserFactoryInterface. | ||
* | ||
* @return UserFactoryInterface | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
* @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 __DEPLOY_VERSION__ | ||
*/ | ||
public function setUserFactory(UserFactoryInterface $userFactory): void | ||
{ | ||
$this->userFactory = $userFactory; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.