CategoryModel::clearCache PHP Method

clearCache() public static method

public static clearCache ( )
    public static function clearCache()
    {
        Gdn::cache()->remove(self::CACHE_KEY);
        self::instance()->collection->flushCache();
    }

Usage Example

Example #1
0
 /**
  * Merge the old user into the new user.
  *
  * @param int $OldUserID The ID of the old user.
  * @param int $NewUserID The ID of the new user.
  */
 public function merge($OldUserID, $NewUserID)
 {
     $OldUser = $this->getID($OldUserID, DATASET_TYPE_ARRAY);
     $NewUser = $this->getID($NewUserID, DATASET_TYPE_ARRAY);
     if (!$OldUser || !$NewUser) {
         throw new Gdn_UserException("Could not find one or both users to merge.");
     }
     $Map = ['UserID', 'Name', 'Email', 'CountVisits', 'CountDiscussions', 'CountComments'];
     $Result = ['MergeID' => null, 'Before' => ['OldUser' => arrayTranslate($OldUser, $Map), 'NewUser' => arrayTranslate($NewUser, $Map)]];
     // Start the merge.
     $MergeID = $this->mergeStart($OldUserID, $NewUserID);
     // Copy all discussions from the old user to the new user.
     $this->mergeCopy($MergeID, 'Discussion', 'InsertUserID', $OldUserID, $NewUserID);
     // Copy all the comments from the old user to the new user.
     $this->mergeCopy($MergeID, 'Comment', 'InsertUserID', $OldUserID, $NewUserID);
     // Update the last comment user ID.
     $this->SQL->put('Discussion', ['LastCommentUserID' => $NewUserID], ['LastCommentUserID' => $OldUserID]);
     // Clear the categories cache.
     CategoryModel::clearCache();
     // Copy all of the activities.
     $this->mergeCopy($MergeID, 'Activity', 'NotifyUserID', $OldUserID, $NewUserID);
     $this->mergeCopy($MergeID, 'Activity', 'InsertUserID', $OldUserID, $NewUserID);
     $this->mergeCopy($MergeID, 'Activity', 'ActivityUserID', $OldUserID, $NewUserID);
     // Copy all of the activity comments.
     $this->mergeCopy($MergeID, 'ActivityComment', 'InsertUserID', $OldUserID, $NewUserID);
     // Copy all conversations.
     $this->mergeCopy($MergeID, 'Conversation', 'InsertUserID', $OldUserID, $NewUserID);
     $this->mergeCopy($MergeID, 'ConversationMessage', 'InsertUserID', $OldUserID, $NewUserID, 'MessageID');
     $this->mergeCopy($MergeID, 'UserConversation', 'UserID', $OldUserID, $NewUserID, 'ConversationID');
     $this->EventArguments['MergeID'] = $MergeID;
     $this->EventArguments['OldUser'] = $OldUser;
     $this->EventArguments['NewUser'] = $NewUser;
     $this->fireEvent('Merge');
     $this->mergeFinish($MergeID);
     $OldUser = $this->getID($OldUserID, DATASET_TYPE_ARRAY);
     $NewUser = $this->getID($NewUserID, DATASET_TYPE_ARRAY);
     $Result['MergeID'] = $MergeID;
     $Result['After'] = ['OldUser' => arrayTranslate($OldUser, $Map), 'NewUser' => arrayTranslate($NewUser, $Map)];
     return $Result;
 }
All Usage Examples Of CategoryModel::clearCache