Extract an item record from a database record.

@param stdClass $record The record.
@return The item record.
186203
protected static function extract_item_record_from_record(stdClass $record) {
        $newrec = new stdClass();
        foreach ($record as $key => $value) {
            if (strpos($key, 'item') !== 0) {
                continue;
            }
            $key = substr($key, 4);
            $newrec->{$key} = $value;
        }
        return $newrec;
    }
198140
public function get_document($record, $options = array()) {

        $context = \context_system::instance();

        // Prepare associative array with data from DB.
        $doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
        // Include all alternate names in title.
        $array = [];
        foreach (get_all_user_name_fields(false, null, null, null, true) as $field) {
            $array[$field] = $record->$field;
        }
        $fullusername = join(' ', $array);
        // Assigning properties to our document.
        $doc->set('title', content_to_text($fullusername, false));
        $doc->set('contextid', $context->id);
        $doc->set('courseid', SITEID);
        $doc->set('itemid', $record->id);
        $doc->set('modified', $record->timemodified);
        $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
        $doc->set('content', content_to_text($record->description, $record->descriptionformat));

        // 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;
    }
901079
protected static function createFromRecord($record)
    {
        if (is_array($record) && $record['cnvEditorHandle']) {
            /** @var \Concrete\Core\Utility\Service\Text $textHelper */
            $textHelper = Core::make('helper/text');
            $class = '\\Concrete\\Core\\Conversation\\Editor\\' . $textHelper->camelcase(
                    $record['cnvEditorHandle']
                ) . 'Editor';
            /** @var Editor $sc Really this could be any kind of editor but this should help code completion a bit */
            $sc = Core::make($class);
            $sc->setPropertiesFromArray($record);

            return $sc;
        }

        return null;
    }
119200
protected static function extract_record($record, $prefix) {
        $result = [];
        $prefixlength = strlen($prefix);
        foreach ($record as $key => $value) {
            if (strpos($key, $prefix) === 0) {
                $result[substr($key, $prefixlength)] = $value;
            }
        }
        return (object) $result;
    }
1047193
public function prune($record = null)
    {
        if ($record) {
            $this->addUsingAlias(RecordTableMap::COL_ID, $record->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }
291757
protected function extractPrimaryKeyValue($record, $returnAs)
    {
        $record = (object) $record;
        $values = [];
        foreach((array) $this->ORMParameters['primaryKey'] as $field) {
            $values[$field] = $record->$field;
        }
        switch($returnAs) {
            case 's':
                return implode('|', $values);
            break;
            case 'a':
                return $values;
            break;
        }   
    }
748724
protected function columnMapRecord($record)
    {
        $adjustedmap = $this->columnMap;
        $newrecord = array();
        foreach ($record as $field => $value) {
            if (isset($adjustedmap[$field])) {
                $newrecord[$adjustedmap[$field]] = $value;
            } else {
                $newrecord[$field] = $value;
            }
        }

        return $newrecord;
    }
1106564
public function getRecordUrl($record)
    {
        if (isset($this->recordOnClick)) {
            return 'javascript:;';
        }

        if (!isset($this->recordUrl)) {
            return null;
        }

        $url = RouterHelper::replaceParameters($record, $this->recordUrl);
        return Backend::url($url);
    }
878340
public static function getValues(GedcomRecord $record = null): array
    {
        $values = [];
        foreach (self::TYPES as $type) {
            $values[$type] = self::getValue($type, $record);
        }
        uasort($values, '\Fisharebest\Webtrees\I18N::strcasecmp');

        return $values;
    }
698216
public function assignRecord(array $record, DB $database)
    {
        $dao = $this->getDAO();
        $table = $dao->getTable($database);
        $pkey = $table->getPrimaryColumns();
        if ($pkey !== null)
        {
            $this->_id = array();
            foreach ($pkey as $col)
                $this->_id[$col->getName()] = $record[$col->getName()];
        }
        else
            $this->_id = null;

        $this->_record = $record;
        $this->_changed = array();
        $this->setSourceDB($database);
        $this->init();

        $columns = $table->getColumns($database);
        foreach ($columns as $name => $def)
        {
            if (!array_key_exists($name, $this->_record))
                continue;

            $this->_record[$name] = $def->afterFetchFilter($this->_record[$name]);
            
            // Synchronize local variables
            if (property_exists($this, $name))
                $this->$name = $this->_record[$name];
        }
        return $this;
    }
134443
public static function update_category(stdClass $record) {
        $category = new category($record->id);
        $category->from_record($record);

        $result = $category->update();

        return $category;
    }
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;
    }
731004
private function extract($record,$level) {
		extract($this->map);
		
		$out = $record[$model];
		
		foreach($relation as $modelName => $type ) {
			$key =  (in_array($type, array('hasOne','belongsTo')))? '_id' : '_ids';
			$key = strtolower($modelName).$key;
			$association = $record[$modelName];
			
			if (isset($association[0])){
				$out[$key] =  Hash::extract($association,'{n}.id');
			} else {
				if($association['id'] === null){
					continue;
				}
				$out[$key] = $association['id'];
			}
			
			$this->associationsMerege($modelName,$association);
			
		}

		$this->models[ Inflector::tableize($model)][] = $out;
	}
1044711
protected static function toMongoObjects($record)
    {
        if (!empty($record)) {
            foreach ($record as $key => $data) {
                if (!is_object($data)) {
                    if (is_string($data) && (static::DEFAULT_ID_FIELD == $key)) {
                        $record[$key] = static::idToMongoId($data);
                    } elseif (is_array($data)) {
                        if (1 === count($data)) {
                            // using typed definition, i.e. {"$date" : "2014-08-02T08:40:12.569Z" }
                            if (array_key_exists('$date', $data)) {
                                $temp = $data['$date'];
                                if (empty($temp)) {
                                    // empty means create with current time
                                    $record[$key] = new UTCDateTime(time() * 1000);
                                } elseif (is_string($temp)) {
                                    $record[$key] = new UTCDateTime(strtotime($temp) * 1000);
                                } elseif (is_int($temp)) {
                                    $record[$key] = new UTCDateTime($temp * 1000);
                                }
                            } elseif (isset($data['$id'])) {
                                $record[$key] = static::idToMongoId($data['$id']);
                            } elseif (isset($data['$oid'])) {
                                $record[$key] = static::idToMongoId($data['$oid']);
                            } else {
                                $record[$key] = static::toMongoObjects($data);
                            }
                        }
                    }
                }
            }
        }

        return $record;
    }
807905
protected function cleanup($record)
    {
        // Translate Throwable (Exception || Error) object into simple array
        if ($this->convertThrowable && $record instanceof Throwable) {
            $record = [
                'message'  => $record->getMessage(),
                'line'     => $record->getLine(),
                'file'     => $record->getFile(),
                'class'    => get_class($record),
                'code'     => $record->getCode(),
                'trace'    => $record->getTrace(),
                'previous' => $record->getPrevious(),
            ];
        }

        // Translate Traversable object into simple array
        if ($this->convertTraversable && $record instanceof Traversable) {
            $record = (array)$record;
        }

        // Traverse over array
        if (is_array($record)) {
            $clean = [];
            foreach ($record as $key => $value) {
                // Remove elements with null value
                if ($this->removeNull && is_null($value)) {
                    unset($clean[$key]);
                    continue;
                }
                $clean[$key] = $this->cleanup($value);
            }

            return $clean;
        }

        // Strip unwanted strings from simple scalar values
        if ($this->stripTags && is_scalar($record)) {
            return str_replace($this->stripTags, '', $record);
        }

        // Return original value if not scalar or array
        return $record;
    }
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;
    }
213422
protected static function extractEvent($job)
    {
        return isset($job->data[0]) && is_object($job->data[0])
                        ? $job->data[0]
                        : new stdClass;
    }