Returns the documents associated with this glossary entry id.

@param stdClass $entry glossary entry.
@param array    $options
@return \core_search\document
553229
public function get_document($entry, $options = array()) {
        try {
            $cm = $this->get_cm('data', $entry->dataid, $entry->course);
            $context = \context_module::instance($cm->id);
        } catch (\dml_missing_record_exception $ex) {
            // Notify it as we run here as admin, we should see everything.
            debugging('Error retrieving mod_data ' . $entry->id . ' document, not all required data is available: ' .
                $ex->getMessage(), DEBUG_DEVELOPER);
            return false;
        } catch (\dml_exception $ex) {
            // Notify it as we run here as admin, we should see everything.
            debugging('Error retrieving mod_data' . $entry->id . ' document: ' . $ex->getMessage(), DEBUG_DEVELOPER);
            return false;
        }

        // Prepare associative array with data from DB.
        $doc = \core_search\document_factory::instance($entry->id, $this->componentname, $this->areaname);
        $doc->set('contextid', $context->id);
        $doc->set('courseid', $entry->course);
        $doc->set('userid', $entry->userid);
        if ($entry->groupid > 0) {
            $doc->set('groupid', $entry->groupid);
        }
        $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
        $doc->set('modified', $entry->timemodified);

        $indexfields = $this->get_fields_for_entries($entry);

        if (count($indexfields) < 2) {
            return false;
        }

        // All fields should be already returned as plain text by data_field_base::get_content_value.
        $doc->set('title', $indexfields[0]);
        $doc->set('content', $indexfields[1]);

        if (isset($indexfields[2])) {
            $doc->set('description1', $indexfields[2]);
        }

        if (isset($indexfields[3])) {
            $doc->set('description2', $indexfields[3]);
        }

        return $doc;
    }
802132
public function getPopular(array $options = [], array $headers = [])
    {
        return $this->getFactory()->createResultCollection(
            $this->getApi()->getPopular($options, $headers)
        );
    }
1114741
public function getOnTheAir(array $options = [], array $headers = [])
    {
        return $this->getFactory()->createResultCollection(
            $this->getApi()->getOnTheAir($options, $headers)
        );
    }
177160
public function get_document($record, $options = array()) {
        try {
            $cm = $this->get_cm('wiki', $record->wikiid, $record->courseid);
            $context = \context_module::instance($cm->id);
        } catch (\dml_missing_record_exception $ex) {
            // Notify it as we run here as admin, we should see everything.
            debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document, not all required data is available: ' .
                $ex->getMessage(), DEBUG_DEVELOPER);
            return false;
        } catch (\dml_exception $ex) {
            // Notify it as we run here as admin, we should see everything.
            debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document: ' . $ex->getMessage(), DEBUG_DEVELOPER);
            return false;
        }

        // Make a page object without extra fields.
        $page = clone $record;
        unset($page->courseid);
        unset($page->wikiid);

        // Conversion based wiki_print_page_content().
        // Check if we have passed the cache time.
        if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
            $content = wiki_refresh_cachedcontent($page);
            $page = $content['page'];
        }
        // Convert to text.
        $content = content_to_text($page->cachedcontent, FORMAT_MOODLE);

        // Prepare associative array with data from DB.
        $doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
        $doc->set('title', content_to_text($record->title, false));
        $doc->set('content', $content);
        $doc->set('contextid', $context->id);
        $doc->set('courseid', $record->courseid);
        if ($record->groupid > 0) {
            $doc->set('groupid', $record->groupid);
        }
        $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
        $doc->set('modified', $record->timemodified);

        // Check if this document should be considered new.
        if (isset($options['lastindexedtime']) && ($options['lastindexedtime'] < $record->timecreated)) {
            // If the document was created after the last index time, it must be new.
            $doc->set_is_new(true);
        }

        return $doc;
    }
98973
public function getResults(array $options = []) : ?SavedSearch
    {
        $this->setContainerId($options['entity']);

        $table = TableRegistry::get('Search.SavedSearches');

        /** @var \Search\Model\Entity\SavedSearch|null */
        $savedSearch = $table->find()
            ->where(['id' => $this->widget->get('widget_id')])
            ->enableHydration(true)
            ->first();

        if (null === $savedSearch) {
            $this->errors[] = 'No data found for this entity';

            return null;
        }

        /** @var \Cake\Datasource\RepositoryInterface */
        $table = TableRegistry::get($savedSearch->get('model'));

        $search = new Search($table, $options['user']);
        // keeps backward compatibility
        $entity = $search->reset($savedSearch);
        if (null === $entity) {
            $this->errors[] = 'Failed to reset entity';

            return null;
        }
        $content = $entity->get('content');
        $content['saved'] = Validator::validateData($table, $content['saved'], $options['user']);
        $entity->set('content', $content);

        $this->options['fields'] = Utility::instance()->getSearchableFields($table, $options['user']);
        $this->options['associationLabels'] = Utility::instance()->getAssociationLabels($table);

        $this->data = $entity;

        return $this->data;
    }
957073
protected function getCacheKey($value, $options)
    {
        if (is_scalar($value)) {
            $data = $value;
        } elseif (is_array($value) && '=' == $value[0]) {
            $data = $value[1];
        }
        if (isset($data)) {
            return 'mongo:' . $options['table'] . '|' . $data;
        }
        return null;
    }
145651
protected function getPropertiesFromAtomEntry(Entry $entry)
    {
        $result = [];
        $content = $entry->getContent();
        if (!empty($content)) {
            $result = ContentPropertiesSerializer::unserialize(
                $content->getXml()->children(Resources::DSM_XML_NAMESPACE)
            );
        }

        return $result;
    }
139595
public function toLdap(array $entry)
    {
        $toLdap = [];

        foreach ($entry as $attribute => $value) {
            $toLdap[$this->schema->getAttributeToLdap($attribute)] = $value;
        }

        return $toLdap;
    }
244606
public function get_document($record, $options = array()) {

        // Check if user still exists, before proceeding.
        $user = \core_user::get_user($options['user1id'], 'deleted');
        if ($user->deleted == 1) {
            return false;
        }

        // Get user context.
        try {
            $usercontext = \context_user::instance($options['user1id']);
        } catch (\moodle_exception $ex) {
            // Notify it as we run here as admin, we should see everything.
            debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document, not all required data is available: ' .
                    $ex->getMessage(), DEBUG_DEVELOPER);
            return false;
        }
        // Prepare associative array with data from DB.
        $doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
        $doc->set('title', content_to_text($record->subject, false));
        $doc->set('itemid', $record->id);
        $doc->set('content', content_to_text($record->smallmessage, false));
        $doc->set('contextid', $usercontext->id);
        $doc->set('courseid', SITEID);
        $doc->set('owneruserid', $options['user1id']);
        $doc->set('userid', $options['user2id']);
        $doc->set('modified', $record->timecreated);

        // Check if this document should be considered new.
        if (isset($options['lastindexedtime']) && $options['lastindexedtime'] < $record->timecreated) {
            // If the document was created after the last index time, it must be new.
            $doc->set_is_new(true);
        }

        return $doc;
    }
370370
public static function query($options = array())
	{
		$query = Query_Soft::forge(get_called_class(), static::connection(), $options);

		if (static::get_filter_status())
		{
			//Make sure we are filtering out soft deleted items
			$query->set_soft_filter(static::soft_delete_property('deleted_field', static::$_default_field_name));
		}

		return $query;
	}
476394
public static function getConnection(array $options): Client
    {
        if (self::$connection === null) {
            $builder = new ClientBuilder([
                'cw.endpoint_uri' => $options['environment'] == 0 ? CodesWholesale::SANDBOX_ENDPOINT : CodesWholesale::LIVE_ENDPOINT,
                'cw.client_id' => $options['environment'] == 0 ? self::SANDBOX_CLIENT_ID : $options['client_id'],
                'cw.client_secret' => $options['environment'] == 0 ? self::SANDBOX_CLIENT_SECRET : $options['client_secret'],
                'cw.token_storage' => isset($options['db']) && $options['db'] instanceof \PDO ? new TokenDatabaseStorage($options['db'], $options['prefix']) : new TokenSessionStorage(),
                'cw.client.headers' => [
                    'User-Agent' => $options['client_headers'],
                ],
                'cw.signature' => isset($options['signature']) ? $options['signature'] : self::SANDBOX_SIGNATURE
            ]);

            self::$connection = $builder->build();
       }
        
        return self::$connection;
    }
777153
public function getCredentialFields($strategy, array $options = [])
    {
        $options['httpParams'][':strategy'] = $strategy;

        return $this->kuzzle->query($this->buildQueryArgs('getCredentialFields'), [], $options)['result'];
    }
1201581
protected function getCacheKey($value, $options)
    {
        if (is_scalar($value)) {
            $data = $value;
        } elseif (is_array($value) && 'eq' == strtolower($value[0])) {
            $data = $value[1];
        }

        if (isset($data)) {
            return 'mongo:' . $options['table'] . '|' . $data;
        } else {
            return md5(serialize($options));
        }
    }
363252
public function getCredentials($strategy, $kuid, array $options = [])
    {
        $options['httpParams'][':strategy'] = $strategy;
        $options['httpParams'][':kuid'] = $kuid;

        return $this->kuzzle->query($this->buildQueryArgs('getCredentials'), [], $options)['result'];
    }
1349760
public function getDocument($id, array $options = [])
    {
        $endpoint = new \Elasticsearch\Endpoints\Get();
        $endpoint->setID($id);
        $endpoint->setParams($options);

        $response = $this->requestEndpoint($endpoint);
        $result = $response->getData();

        if (!isset($result['found']) || false === $result['found']) {
            throw new NotFoundException('doc id '.$id.' not found');
        }

        if (isset($result['fields'])) {
            $data = $result['fields'];
        } elseif (isset($result['_source'])) {
            $data = $result['_source'];
        } else {
            $data = [];
        }

        $document = new Document($id, $data, $this->getName(), $this->getIndex());
        $document->setVersion($result['_version']);

        return $document;
    }
156988
public static function find($options = [])
    {
        $options = Set::extend(static::query(), $options);
        $schema = static::definition();
        return $schema->query(['query' => $options] + ['finders' => static::finders()]);
    }
868739
public static function get_all($options = []) {
        global $DB;

        $coursecatrecordcache = cache::make('core', 'coursecatrecords');

        $catcontextsql = \context_helper::get_preload_record_columns_sql('ctx');
        $catsql = "SELECT cc.*, {$catcontextsql}
                     FROM {course_categories} cc
                     JOIN {context} ctx ON cc.id = ctx.instanceid";
        $catsqlwhere = "WHERE ctx.contextlevel = :contextlevel";
        $catsqlorder = "ORDER BY cc.depth ASC, cc.sortorder ASC";

        $catrs = $DB->get_recordset_sql("{$catsql} {$catsqlwhere} {$catsqlorder}", [
            'contextlevel' => CONTEXT_COURSECAT,
        ]);

        $types['categories'] = [];
        $categories = [];
        $toset = [];
        foreach ($catrs as $record) {
            $category = new self($record);
            $toset[$category->id] = $category;

            if (!empty($options['returnhidden']) || $category->is_uservisible()) {
                $categories[$record->id] = $category;
            }
        }
        $catrs->close();

        $coursecatrecordcache->set_many($toset);

        return $categories;

    }