[ 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) 2005 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE 8 */ 9 10 namespace Joomla\CMS\Application; 11 12 use Joomla\CMS\User\User; 13 use Joomla\CMS\User\UserFactoryInterface; 14 15 // phpcs:disable PSR1.Files.SideEffects 16 \defined('JPATH_PLATFORM') or die; 17 // phpcs:enable PSR1.Files.SideEffects 18 19 /** 20 * Trait for application classes which are identity (user) aware 21 * 22 * @since 4.0.0 23 */ 24 trait IdentityAware 25 { 26 /** 27 * The application identity object. 28 * 29 * @var User 30 * @since 4.0.0 31 */ 32 protected $identity; 33 34 /** 35 * UserFactoryInterface 36 * 37 * @var UserFactoryInterface 38 * @since 4.0.0 39 */ 40 private $userFactory; 41 42 /** 43 * Get the application identity. 44 * 45 * @return User 46 * 47 * @since 4.0.0 48 */ 49 public function getIdentity() 50 { 51 return $this->identity; 52 } 53 54 /** 55 * Allows the application to load a custom or default identity. 56 * 57 * @param User $identity An optional identity object. If omitted, a null user object is created. 58 * 59 * @return $this 60 * 61 * @since 4.0.0 62 */ 63 public function loadIdentity(User $identity = null) 64 { 65 $this->identity = $identity ?: $this->userFactory->loadUserById(0); 66 67 return $this; 68 } 69 70 /** 71 * Set the user factory to use. 72 * 73 * @param UserFactoryInterface $userFactory The user factory to use 74 * 75 * @return void 76 * 77 * @since 4.0.0 78 */ 79 public function setUserFactory(UserFactoryInterface $userFactory) 80 { 81 $this->userFactory = $userFactory; 82 } 83 }
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 |