Checks the recordOrigin attribute of a record and will throw an exception if value is not allowed

@param Object $record record

@return void
503492
protected function checkIfOriginRecord($record)
    {
        if ($record instanceof RecordOriginInterface
            && !$record->isRecordOriginModifiable()
        ) {
            $values = $this->notModifiableOriginRecords;
            $originValue = strtolower(trim($record->getRecordOrigin()));

            if (in_array($originValue, $values)) {
                $msg = sprintf("Must not be one of the following keywords: %s", implode(', ', $values));

                throw new RecordOriginModifiedException($msg);
            }
        }
    }
1057395
private function decodeCall($record): AbstractInvoke
    {
        $record = $this->preParse($record);

        if ($this->isValidCall($record)) {
            $unit = new Invoke($record['id'], $record['method'], $record['params'] ?? []);
        } elseif ($this->isValidNotification($record)) {
            $unit = new Notification($record['method'], $record['params']);
        } else {
            $unit = new Error(new InvalidRequestException());
        }

        return $unit;
    }
191675
public function processRecord(Record $record)
    {

        $backtrace = debug_backtrace();
        $backtrace = $backtrace[5];

        $extraData = $record->getExtra();

        $extraData['file'] = $backtrace['file'];
        $extraData['line'] = $backtrace['line'];

        $record->setExtra($extraData);
    }
248827
public function getTranslationOriginalUidIfTranslated($table, array $record, $originalUid)
    {
        if (!$this->isLocalizedRecord($table, $record)) {
            return $originalUid;
        }

        return $this->getTranslationOriginalUid($table, $record);
    }
314661
public function setRecord($record) {
    $this->resetObject();
    $newRecord = array();
    foreach ($this->fields as $field_name => $field) {
      if (!empty($record[$field_name])) {
        $newRecord[$field_name] = $record[$field_name];
      }
      else {
        $newRecord[$field_name] = ''; //Adds the field but with empty string.
      }
    }
    $this->record = $newRecord;
    $this->fetchedRecord = $record;

    return $this;
  }
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;
    }
1272041
public static function set_context_instance($record) {
        if ($instance = context_instance::get_record_by_contextid($record->contextid, false)) {
            // Update.
            $instance->from_record($record);

            if (empty($record->purposeid) && empty($record->categoryid)) {
                // We accept one of them to be null but we delete it if both are null.
                self::unset_context_instance($instance);
                return;
            }

        } else {
            // Add.
            $instance = new context_instance(0, $record);
        }
        $instance->save();

        return $instance;
    }
1263754
public function normalizeValues(Record $record)
    {

        foreach ($record as $key => $value) {
            $setter = 'set' . ucfirst($key);
            $record->$setter($this->normalizeValue($value));
        }
    }
295565
public function useRecord(Record $record): void
    {
        $this->records->add($this->name, $record);
    }
568542
protected function open( Record $record = null )
    {
        if ($this->isOpen) {
            return;
        }

        $this->recordCount = 0;
        $this->isOpen      = true;

        $this->writer->open();
        $this->writeHeader( $record );
    }
595344
public function findExistingObject($record, $columnMap = [])
    {
        $SNG_objectClass = singleton($this->objectClass);
        // checking for existing records (only if not already found)

        foreach ($this->duplicateChecks as $fieldName => $duplicateCheck) {
            $existingRecord = null;
            if (is_string($duplicateCheck)) {
                // Skip current duplicate check if field value is empty
                if (empty($record[$duplicateCheck])) {
                    continue;
                }

                // Check existing record with this value
                $dbFieldValue = $record[$duplicateCheck];
                $existingRecord = DataObject::get($this->objectClass)
                    ->filter($duplicateCheck, $dbFieldValue)
                    ->first();

                if ($existingRecord) {
                    return $existingRecord;
                }
            } elseif (is_array($duplicateCheck) && isset($duplicateCheck['callback'])) {
                if ($this->hasMethod($duplicateCheck['callback'])) {
                    $existingRecord = $this->{$duplicateCheck['callback']}($record[$fieldName], $record);
                } elseif ($SNG_objectClass->hasMethod($duplicateCheck['callback'])) {
                    $existingRecord = $SNG_objectClass->{$duplicateCheck['callback']}($record[$fieldName], $record);
                } else {
                    user_error("CsvBulkLoader::processRecord():"
                        . " {$duplicateCheck['callback']} not found on importer or object class.", E_USER_ERROR);
                }

                if ($existingRecord) {
                    return $existingRecord;
                }
            } else {
                user_error('CsvBulkLoader::processRecord(): Wrong format for $duplicateChecks', E_USER_ERROR);
            }
        }

        return false;
    }
1228958
public function handle( IRecord $record )
    {
        // check if we should be logging this record
        if ( $record->getLevel() >= $this->_level )
        {
            $this->_mailer->isHtml( TRUE );
            $this->_mailer->setSubject( $record->getTitle() );

            $content = $this->getFormatter()->format( $record );

            $this->_mailer->setBody( $content );

            $this->_mailer->send();
        }
    }
430128
protected function writeError(array $record)
    {
        $exception = new WhoopsErrorException(
            $record['message'],
            $record['level'],
            0,
            $record['context']['file'],
            $record['context']['line']
        );

        $this->writeException($exception);
    }
844388
private function preParse($record)
    {
        $container = $this->preParse->handle(new ParserContainer($this, $record));

        if ($container instanceof ParserContainer) {
            return $container->getValue();
        }

        throw new \RuntimeException();
    }
725371
public void init(Record record, String strToCompare, String strSeekSign, Converter pconvFlag, boolean bDontFilterIfNullCompare, BaseField fldToCheck, BaseField fldToCompare)
    {
        m_fldFakeDate = null;
        super.init(record, null, strToCompare, null, pconvFlag, bDontFilterIfNullCompare, fldToCheck, fldToCompare);
        if (strSeekSign == null)
            m_strSeekSign = DBConstants.BLANK;    // I Must do this here because I don't want the default value
    }
673035
public static function set_contextlevel($record) {
        global $DB;

        if ($record->contextlevel != CONTEXT_SYSTEM && $record->contextlevel != CONTEXT_USER) {
            throw new \coding_exception('Only context system and context user can set a contextlevel ' .
                'purpose and retention');
        }

        if ($contextlevel = contextlevel::get_record_by_contextlevel($record->contextlevel, false)) {
            // Update.
            $contextlevel->from_record($record);
        } else {
            // Add.
            $contextlevel = new contextlevel(0, $record);
        }
        $contextlevel->save();

        // We sync with their defaults as we removed these options from the defaults page.
        $classname = \context_helper::get_class_for_level($record->contextlevel);
        list($purposevar, $categoryvar) = data_registry::var_names_from_context($classname);
        set_config($purposevar, $record->purposeid, 'tool_dataprivacy');
        set_config($categoryvar, $record->categoryid, 'tool_dataprivacy');

        return $contextlevel;
    }
796852
protected static function delete($record) {
        global $DB;

        core_tag_tag::delete_instances($record->component, $record->itemtype);

        $DB->delete_records('tag_area',
                array('itemtype' => $record->itemtype,
                    'component' => $record->component));

        // Reset cache.
        cache::make('core', 'tags')->delete('tag_area');
    }