]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Simplify functions regarding locally cached profiles etc.
authorMikael Nordfeldth <mmn@hethane.se>
Thu, 5 Jun 2014 22:32:07 +0000 (00:32 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Thu, 5 Jun 2014 22:32:07 +0000 (00:32 +0200)
classes/Profile.php
classes/User.php
classes/User_group.php

index e4c68724ee69d328c15b29a0bd9e8a63e0449c80..862e8ff11a4f34acecb8c982f116672b9a4b90d3 100644 (file)
@@ -97,37 +97,29 @@ class Profile extends Managed_DataObject
     public function getUser()
     {
         if (!isset($this->_user[$this->id])) {
-            $this->_setUser(User::getKV('id', $this->id));
+            $user = User::getKV('id', $this->id);
+            if (!$user instanceof User) {
+                throw new NoSuchUserException(array('id'=>$this->id));
+            }
+            $this->_user[$this->id] = $user;
         }
         return $this->_user[$this->id];
     }
 
-    public function _setUser(User $user=null)
-    {
-        if (!$user instanceof User) {
-            throw new NoSuchUserException(array('id'=>$this->id));
-        }
-        $this->_user[$this->id] = $user;
-    }
-
     protected $_group = array();
 
     public function getGroup()
     {
         if (!isset($this->_group[$this->id])) {
-            $this->_setGroup(User_group::getKV('profile_id', $this->id));
+            $group = User_group::getKV('profile_id', $this->id);
+            if (!$group instanceof User_group) {
+                throw new NoSuchGroupException(array('profile_id'=>$this->id));
+            }
+            $this->_group[$this->id] = $group;
         }
         return $this->_group[$this->id];
     }
 
-    public function _setGroup(User_group $group=null)
-    {
-        if (!$group instanceof User_group) {
-            throw new NoSuchGroupException(array('profile_id'=>$this->id));
-        }
-        $this->_group[$this->id] = $group;
-    }
-
     public function isGroup()
     {
         try {
index c23b0a0b0ae98f800e76fc5f2da25a9840ca0800..9b3ebed057156389062781bd4865547471d9cec1 100644 (file)
@@ -123,19 +123,15 @@ class User extends Managed_DataObject
     public function getProfile()
     {
         if (!isset($this->_profile[$this->id])) {
-            $this->_setProfile(Profile::getKV('id', $this->id));
+            $profile = Profile::getKV('id', $this->id);
+            if (!$profile instanceof Profile) {
+                throw new UserNoProfileException($this);
+            }
+            $this->_profile[$this->id] = $profile;
         }
         return $this->_profile[$this->id];
     }
 
-    public function _setProfile(Profile $profile=null)
-    {
-        if (!$profile instanceof Profile) {
-            throw new UserNoProfileException($this);
-        }
-        $this->_profile[$this->id] = $profile;
-    }
-
     public function getUri()
     {
         return $this->uri;
index a9dfacd49811a3541a257cd276d986795d6c2d7b..d81449faa1bc61b0286c8f392b28025ff7a7fc62 100644 (file)
@@ -84,19 +84,15 @@ class User_group extends Managed_DataObject
     public function getProfile()
     {
         if (!isset($this->_profile[$this->profile_id])) {
-            $this->_setProfile(Profile::getKV('id', $this->profile_id));
+            $profile = Profile::getKV('id', $this->profile_id);
+            if (!$profile instanceof Profile) {
+                throw new GroupNoProfileException($this);
+            }
+            $this->_profile[$this->profile_id] = $profile;
         }
         return $this->_profile[$this->profile_id];
     }
 
-    public function _setProfile(Profile $profile=null)
-    {
-        if (!$profile instanceof Profile) {
-            throw new GroupNoProfileException($this);
-        }
-        $this->_profile[$this->profile_id] = $profile;
-    }
-
     public static function defaultLogo($size)
     {
         static $sizenames = array(AVATAR_PROFILE_SIZE => 'profile',