Returns the document associated with this section.

@param \stdClass $record
@param array $options
@return \core_search\document
438779
public function get_document($record, $options = array()) {
        global $CFG;
        require_once($CFG->dirroot . '/course/lib.php');

        // Get the context, modinfo, and section.
        try {
            $context = \context_course::instance($record->course);
        } 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;
        }

        // Title - use default if none given.
        $title = get_section_name($record->course, $record->section);

        // 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($title, false));
        $doc->set('content', content_to_text($record->summary, $record->summaryformat));
        $doc->set('contextid', $context->id);
        $doc->set('courseid', $record->course);
        $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
        $doc->set('modified', $record->timemodified);

        return $doc;
    }
1102271
protected function getRecordGridfieldRow($record)
    {
        $this->gridField->setList(new ArrayList(array($record)));
        $rowContent = '';

        foreach ($this->gridField->getColumns() as $column) {
            $colContent = $this->gridField->getColumnContent($record, $column);
            // Null means this columns should be skipped altogether.
            if ($colContent === null) {
                continue;
            }

            $colAttributes = $this->gridField->getColumnAttributes($record, $column);
            $rowContent .= HTML::createTag(
                'td',
                $colAttributes,
                $colContent
            );
        }

        $rowAttributes = array(
            'class' => 'ss-gridfield-item ' . implode(' ', $this->successClasses),
            'data-id' => $record->ID,
            'data-class' => $record->ClassName,
        );
        $row = HTML::createTag(
            'tr',
            $rowAttributes,
            $rowContent
        );
        return $row;
    }
1073270
protected function prepareRecord($record)
    {
        if ($record[static::REMOVE_FLAG_NAME] == 1) {
            return $record;
        }

        $prepared = [];

        /* @var Field $field */
        foreach ($this->fields as $field) {
            $columns = $field->column();

            $value = $this->fetchColumnValue($record, $columns);

            if (is_null($value)) {
                continue;
            }

            if (method_exists($field, 'prepare')) {
                $value = $field->prepare($value);
            }

            if (($field instanceof \Encore\Admin\Form\Field\Hidden) || $value != $field->original()) {
                if (is_array($columns)) {
                    foreach ($columns as $name => $column) {
                        Arr::set($prepared, $column, $value[$name]);
                    }
                } elseif (is_string($columns)) {
                    Arr::set($prepared, $columns, $value);
                }
            }
        }

        $prepared[static::REMOVE_FLAG_NAME] = $record[static::REMOVE_FLAG_NAME];

        return $prepared;
    }
162552
public function get_document($record, $options = array()) {
        return parent::get_document($record, array('user1id' => $record->useridto, 'user2id' => $record->useridfrom));
    }
307739
private function processRecord(array $record): ?int
    {
        $requestId = $record['requestId'];

        $content = 0 === $record['contentLength'] ? null : $record['contentData'];

        if (DaemonInterface::FCGI_BEGIN_REQUEST === $record['type']) {
            $this->processBeginRequestRecord($requestId, $content);
        } elseif (!isset($this->requests[$requestId])) {
            throw new ProtocolException('Invalid request id for record of type: '.$record['type']);
        } elseif (DaemonInterface::FCGI_PARAMS === $record['type']) {
            while (null !== $content && strlen($content) > 0) {
                $this->readNameValuePair($requestId, $content);
            }
        } elseif (DaemonInterface::FCGI_STDIN === $record['type']) {
            if (null !== $content) {
                fwrite($this->requests[$requestId]['stdin'], $content);
            } else {
                // Returns the status code
                return $this->dispatchRequest($requestId);
            }
        } elseif (DaemonInterface::FCGI_ABORT_REQUEST === $record['type']) {
            $this->endRequest($requestId);
        } else {
            throw new ProtocolException('Unexpected packet of type: '.$record['type']);
        }

        return null; // No status code to return
    }
1038009
public static function create_template(stdClass $record) {
        static::require_enabled();
        $template = new template(0, $record);

        // First we do a permissions check.
        if (!$template->can_manage()) {
            throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage',
                'nopermissions', '');
        }

        // OK - all set.
        $template = $template->create();

        // Trigger a template created event.
        \core\event\competency_template_created::create_from_template($template)->trigger();

        return $template;
    }
34343
protected function doFindAndRemove(array $query, array $options = array())
    {
        $document = parent::doFindAndRemove($query, $options);

        if (isset($document)) {
            // Remove the file data from the chunks collection
            $this->riakCollection->chunks->remove(array('files_id' => $document['_id']), $options);
        }

        return $document;
    }
806734
public function getGroup($gridField, $record, $columnName)
    {
        if (!$this->canUnlink($record)) {
            return null;
        }

        return parent::getGroup($gridField, $record, $columnName);
    }
539591
protected static function extract_object_from_record($record, $prefix, $additionalfields = []) {
        $object = new \stdClass();
        foreach ($record as $key => $value) {
            if (preg_match('/^'.preg_quote($prefix, '/').'(.*)/', $key, $matches)) {
                $object->{$matches[1]} = $value;
            }
        }
        if ($additionalfields) {
            foreach ($additionalfields as $key => $value) {
                $object->$key = $value;
            }
        }
        return $object;
    }
172107
public function get_post_from_stdclass(stdClass $record) : post_entity {
        return new post_entity(
            $record->id,
            $record->discussion,
            $record->parent,
            $record->userid,
            $record->created,
            $record->modified,
            $record->mailed,
            $record->subject,
            $record->message,
            $record->messageformat,
            $record->messagetrust,
            $record->attachment,
            $record->totalscore,
            $record->mailnow,
            $record->deleted,
            $record->privatereplyto
        );
    }
1206102
function findRecord(options) {
    let query = getQueryParams(options, ['name', 'content', 'type', 'query']);
    return find(options.domain, query).then(function (result) {
      return new Result(result.data.result);
    });
  }
1371166
public function get_document($record, $options = array()) {

        try {
            $cm = $this->get_cm('forum', $record->forumid, $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;
        }

        // 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('content', content_to_text($record->message, $record->messageformat));
        $doc->set('contextid', $context->id);
        $doc->set('courseid', $record->courseid);
        $doc->set('userid', $record->userid);
        $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
        $doc->set('modified', $record->modified);

        // Store group id if there is one. (0 and -1 both mean not restricted to group.)
        if ($record->groupid > 0) {
            $doc->set('groupid', $record->groupid);
        }

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

        return $doc;
    }
256265
public function getSelector($pkey, array $record)
    {
        if ($pkey !== null && !is_array($pkey))
            throw new InvalidTypeException("Invalid primary key: " . WF::str($pkey));

        // When no primary key is available, we match on all fields
        $is_primary_key = true;
        if ($pkey === null)
        {
            $pkey = array();
            foreach ($record as $k => $v)
                $pkey[$k] = $this->table->getColumn($v);
            $is_primary_key = false;
        }

        // Make sure there are fields to match on
        if (empty($pkey))
            throw new InvalidTypeException("No fields to match on");

        $condition = null;
        foreach ($pkey as $pkey_column => $coldef)
        {
            if ($is_primary_key && (!array_key_exists($pkey_column, $record) || $record[$pkey_column] === null))
                throw new DAOException("Record does not have value for primary key column {$pkey_column}");
            
            $pkey_value = $coldef->beforeInsertFilter($record[$pkey_column]);
            $comparator = new Query\ComparisonOperator("=", $pkey_column, $pkey_value);
            $condition = $condition === null ? $comparator : new Query\BooleanOperator("AND", $condition, $comparator);
        }

        return $condition;
    }
385042
public function getRecord($ipAddress = 'me', $type = 'country', array $options = array())
    {
        $provider = isset($options['provider']) ? $options['provider'] : 'reader';
        $locales = isset($options['locales']) ? $options['locales'] : array('en');

        if ('client' == $provider) {
            $provider = $this->getClient($locales);
        } else {
            $provider = $this->getReader($type, $locales);
        }

        $method = preg_replace_callback('/_([a-z])/', function ($match) {
            return strtoupper($match[1]);
        }, $type);

        if (!method_exists($provider, $method)) {
            throw new GeoIpException(
                sprintf('The method "%s" does not exist for %s', $method, get_class($provider))
            );
        }

        return $provider->{$method}($ipAddress);
    }
675263
public function recordFactory(File_MARC_Record $record)
    {
        try {
            $recordType = self::getRecordType($record);
        } catch (UnknownRecordType $e) {
            return new Record($record);
        }
        switch ($recordType) {
            case Marc21::BIBLIOGRAPHIC:
                return new BibliographicRecord($record);

            case Marc21::HOLDINGS:
                return new HoldingsRecord($record);

            case Marc21::AUTHORITY:
                return new AuthorityRecord($record);
        }
    }
981839
protected function getDocument($record)
    {
        $document = new Document();
        $document->setData($record);
        $document->setType($this->type);
        $document->setIndex($this->index);

        return $document;
    }
803240
protected static function extract_grade_grade_from_record(stdClass $record, $ishistory = false) {
        $prefix = $ishistory ? 'ggh_' : 'gg_';
        $ggrecord = static::extract_record($record, $prefix);
        if ($ishistory) {
            // The grade history is not a real grade_grade so we remove the ID.
            $historyid = $ggrecord->id;
            unset($ggrecord->id);
        }
        $gg = new grade_grade($ggrecord, false);

        // There is a grade item in the record.
        if (!empty($record->gi_id)) {
            $gi = new grade_item(static::extract_record($record, 'gi_'), false);
            $gg->grade_item = $gi;  // This is a common hack throughout the grades API.
        }

        // Load the scale, when it still exists.
        if (!empty($gi->scaleid) && !empty($record->sc_id)) {
            $scalerec = static::extract_record($record, 'sc_');
            $gi->scale = new grade_scale($scalerec, false);
            $gi->scale->load_items();
        }

        if ($ishistory) {
            $gg->historyid = $historyid;
        }

        return $gg;
    }