]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
pivotGet moved into Managed_DataObject
authorMikael Nordfeldth <mmn@hethane.se>
Thu, 29 Aug 2013 08:13:07 +0000 (10:13 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Thu, 29 Aug 2013 08:13:07 +0000 (10:13 +0200)
classes/Avatar.php
classes/Managed_DataObject.php
classes/Memcached_DataObject.php
classes/Notice.php
classes/Profile.php
lib/inboxnoticestream.php
lib/noticelist.php
lib/scopingnoticestream.php

index 8cff14273c8abc66999a94539cb579845de86bb4..aed6ea0dd2892ec3702c3d09117c6c34bc267f8c 100644 (file)
@@ -22,11 +22,6 @@ class Avatar extends Managed_DataObject
 
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
-
-       static function pivotGet($keyCol, $keyVals, $otherCols)
-       {
-           return Memcached_DataObject::pivotGet('Avatar', $keyCol, $keyVals, $otherCols);
-       }
        
     public static function schemaDef()
     {
index d173deff2495545fd106d9c01794fb804032f5d8..4ec8de669d3dd4abd39f43450e587dfd35e2d945 100644 (file)
@@ -61,6 +61,20 @@ abstract class Managed_DataObject extends Memcached_DataObject
         return parent::pkeyGetClass(get_called_class(), $kv);
     }
 
+    /**
+     * Get multiple items from the database by key
+     *
+     * @param string  $keyCol    name of column for key
+     * @param array   $keyVals   key values to fetch
+     * @param array   $otherCols Other columns to hold fixed
+     *
+     * @return array Array mapping $keyVals to objects, or null if not found
+     */
+       static function pivotGet($keyCol, array $keyVals, array $otherCols=array())
+       {
+           return parent::pivotGetClass(get_called_class(), $keyCol, $keyVals, $otherCols);
+       }
+
     /**
      * Get a multi-instance object
      *
index aa3a70395f07f81c5405f818232e5eae0c7ceeed..262f83b83ccfb99b137d33099c21d135ff073b61 100644 (file)
@@ -76,7 +76,7 @@ class Memcached_DataObject extends Safe_DataObject
      */
     function multiGet($cls, $keyCol, $keyVals, $skipNulls=true)
     {
-        $result = self::pivotGet($cls, $keyCol, $keyVals);
+        $result = self::pivotGetClass($cls, $keyCol, $keyVals);
 
         $values = array_values($result);
 
@@ -103,7 +103,7 @@ class Memcached_DataObject extends Safe_DataObject
      *
      * @return array Array mapping $keyVals to objects, or null if not found
      */
-    static function pivotGet($cls, $keyCol, $keyVals, $otherCols = array())
+    static function pivotGetClass($cls, $keyCol, array $keyVals, array $otherCols = array())
     {
         if (!is_a($cls, __CLASS__, true)) {
             throw new Exception('Trying to fetch ' . __CLASS__ . ' into a non-related class');
@@ -292,7 +292,7 @@ class Memcached_DataObject extends Safe_DataObject
         }
 
         if (count($allPkeys) > 0) {
-            $keyResults = self::pivotGet($cls, $pkeyCols, $allPkeys);
+            $keyResults = self::pivotGetClass($cls, $pkeyCols, $allPkeys);
 
             foreach ($pkeyMap as $keyVal => $pkeyList) {
                 foreach ($pkeyList as $pkeyVal) {
index 4f78343798e18ed571151f270eb8e5b0ae834520..e71b63ba47b9c91887a5169a98a554a583a0eb45 100644 (file)
@@ -2600,7 +2600,7 @@ class Notice extends Managed_DataObject
                
                $ids = array_unique($ids);
                
-               return Memcached_DataObject::pivotGet('Profile', 'id', $ids); 
+               return Profile::pivotGet('id', $ids); 
        }
        
        static function fillGroups(&$notices)
@@ -2621,7 +2621,7 @@ class Notice extends Managed_DataObject
                
                $gids = array_unique($gids);
                
-               $group = Memcached_DataObject::pivotGet('User_group', 'id', $gids);
+               $group = User_group::pivotGet('id', $gids);
                
                foreach ($notices as $notice)
                {
@@ -2660,7 +2660,7 @@ class Notice extends Managed_DataObject
 
         $fileIds = array_unique($fileIds);
 
-               $fileMap = Memcached_DataObject::pivotGet('File', 'id', $fileIds);
+               $fileMap = File::pivotGet('id', $fileIds);
 
                foreach ($notices as $notice)
                {
index 93eb41bdcb7bfe4eb43d047d904b190164148205..c8f44c007b03c3fa24ba9f76cea53651ad9d00a6 100644 (file)
@@ -1494,8 +1494,4 @@ class Profile extends Managed_DataObject
     {
         return $this;
     }
-
-    static function pivotGet($key, $values, $otherCols=array()) {
-        return Memcached_DataObject::pivotGet('Profile', $key, $values, $otherCols);
-    }
 }
index fee0e8a096ba608221dc080438e60da9886edf97..27fec9518b62110b835d13fbe09d0ee84072cdbd 100644 (file)
@@ -144,7 +144,7 @@ class RawInboxNoticeStream extends NoticeStream
 
             $ids = $this->getNoticeIds($offset, $limit, $sinceId, $maxId);
 
-            $notices = Memcached_DataObject::pivotGet('Notice', 'id', $ids);
+            $notices = Notice::pivotGet('id', $ids);
 
             // By default, takes out false values
 
index 7f38cf005b29469dddca30197946a0cc78da5b4d..c242417e5ab0f91b61145c81514625f64dcf36fd 100644 (file)
@@ -147,8 +147,8 @@ class NoticeList extends Widget
                     $ids[] = $notice->id;
                 }
        
-                Memcached_DataObject::pivotGet('Fave', 'notice_id', $ids, array('user_id' => $p->id));
-                Memcached_DataObject::pivotGet('Notice', 'repeat_of', $ids, array('profile_id' => $p->id));
+                Fave::pivotGet('notice_id', $ids, array('user_id' => $p->id));
+                Notice::pivotGet('repeat_of', $ids, array('profile_id' => $p->id));
             }
 
             Event::handle('EndNoticeListPrefill', array(&$notices, &$profiles, $avatarSize));
index 9a101fa3ac03cd314f8e76ec3299ff077d1c354d..c1651d5a30b1c347c33803091ddf441d5b65f1b3 100644 (file)
@@ -89,10 +89,9 @@ class ScopingNoticeStream extends FilteringNoticeStream
                 $pids[] = $profile->id;
             }
             
-            Memcached_DataObject::pivotGet('Profile_role',
-                                           'profile_id',
-                                           $pids,
-                                           array('role' => Profile_role::SILENCED));
+            Profile_role::pivotGet('profile_id',
+                                   $pids,
+                                   array('role' => Profile_role::SILENCED));
         }
     }
 }