OCA\OcSms\Lib\ContactCache::loadContacts PHP Method

loadContacts() private method

Partially importe this function from owncloud Chat app https://github.com/owncloud/chat/blob/master/app/chat.php
private loadContacts ( )
    private function loadContacts()
    {
        $this->contacts = array();
        $this->contactsInverted = array();
        // Cache country because of loops
        $configuredCountry = $this->cfgMapper->getCountry();
        $cm = $this->contactsManager;
        if ($cm == null) {
            return;
        }
        $result = $cm->search('', array('FN'));
        foreach ($result as $r) {
            if (isset($r["TEL"])) {
                $phoneIds = $r["TEL"];
                if (is_array($phoneIds)) {
                    $countPhone = count($phoneIds);
                    for ($i = 0; $i < $countPhone; $i++) {
                        $phoneNumber = preg_replace("#[ ]#", "", $phoneIds[$i]);
                        $this->pushPhoneNumberToCache($phoneNumber, $r["FN"], $configuredCountry);
                    }
                } else {
                    $phoneNumber = preg_replace("#[ ]#", "", $phoneIds);
                    $this->pushPhoneNumberToCache($phoneNumber, $r["FN"], $configuredCountry);
                }
                if (isset($r["PHOTO"])) {
                    // Remove useless prefix
                    $ocversion = \OCP\Util::getVersion();
                    $photoURL = preg_replace("#^VALUE=uri:#", "", $r["PHOTO"], 1);
                    $this->contactPhotos[$r["FN"]] = $photoURL;
                }
            }
        }
    }