Horde_ActiveSync_Driver_Base::_getFolderUidForBackendId PHP Method

_getFolderUidForBackendId() protected method

Get an activesync uid for the given backend serverid. If we've seen this serverid before, return the previously created uid, otherwise return a new one.
Since: 2.4.0
protected _getFolderUidForBackendId ( string $id, string $type = null, string $old_id = null ) : string
$id string The server's current folder name E.g., INBOX
$type string The folder type, a Horde_ActiveSync::FOLDER_TYPE_* constant. If empty, assumes FOLDER_TYPE_USER_MAIL
$old_id string The previous folder name for this folder, if the folder is being renamed. @since 2.15.0 @todo This is tempoarary until 3.0 (H6) when we will have the collection manager take care of ALL of the folder name <-> UID mapping management.
return string A unique identifier for the specified backend folder id. The first character indicates the foldertype as such: 'F' - Email 'C' - Contact 'A' - Appointment 'T' - Task 'N' - Note
    protected function _getFolderUidForBackendId($id, $type = null, $old_id = null)
    {
        // Always use 'RI' for Recipient cache.
        if ($id == 'RI') {
            return 'RI';
        }
        $map = $this->_state->getFolderUidToBackendIdMap();
        // Rename?
        if (!empty($old_id) && !empty($map[$old_id])) {
            $this->_tempMap[$id] = $map[$old_id];
        }
        if (!empty($map[$id])) {
            return $map[$id];
        } elseif (!empty($this->_tempMap[$id])) {
            return $this->_tempMap[$id];
        }
        // Convert TYPE to CLASS
        $type = $this->_getClassFromType($type);
        $rMap = array_flip($this->_typeMap);
        $prefix = $rMap[$type];
        // None found, generate a new UID.
        $this->_tempMap[$id] = sprintf('%s%04x%04x', $prefix, mt_rand(0, 0xffff), mt_rand(0, 0xffff));
        $this->_logger->info(sprintf('[%s] Creating new folder uuid for %s: %s', getmypid(), $id, $this->_tempMap[$id]));
        return $this->_tempMap[$id];
    }