[MCR] Factor PageUpdater out of WikiPage
[lhc/web/wiklou.git] / includes / user / User.php
index c5fa05a..7c88598 100644 (file)
@@ -636,6 +636,27 @@ class User implements IDBAccessObject, UserIdentity {
                return $u;
        }
 
+       /**
+        * Returns a User object corresponding to the given UserIdentity.
+        *
+        * @since 1.32
+        *
+        * @param UserIdentity $identity
+        *
+        * @return User
+        */
+       public static function newFromIdentity( UserIdentity $identity ) {
+               if ( $identity instanceof User ) {
+                       return $identity;
+               }
+
+               return self::newFromAnyId(
+                       $identity->getId() === 0 ? null : $identity->getId(),
+                       $identity->getName() === '' ? null : $identity->getName(),
+                       $identity->getActorId() === 0 ? null : $identity->getActorId()
+               );
+       }
+
        /**
         * Static factory method for creation from an ID, name, and/or actor ID
         *