Make sure the returned record is a new instance an does only contain properties of it's
current view

@param AbstractRecord $record - multi view record !
498902
protected function exportRecord(AbstractRecord $record, DataDimensions $dataDimensions)
    {
        $precalculate      = $this->precalculateExportRecord($record, $dataDimensions);
        $allowedProperties = array_intersect_key($record->getProperties(), $precalculate['allowedProperties']);
        $record            = clone $record;
        $record->setProperties($allowedProperties);

        return $record;
    }
848858
protected function set_related($record) {
        $comp = $record->createdcomp;
        if ($record->relatedidnumbers) {
            $allidnumbers = explode(',', $record->relatedidnumbers);
            foreach ($allidnumbers as $rawidnumber) {
                $idnumber = str_replace('%2C', ',', $rawidnumber);

                if (isset($this->flat[$idnumber])) {
                    $relatedcomp = $this->flat[$idnumber]->createdcomp;
                    api::add_related_competency($comp->get('id'), $relatedcomp->get('id'));
                }
            }
        }
        foreach ($record->children as $child) {
            $this->set_related($child);
        }
    }
1160197
private function processDoctrineLogRecord(array $record)
    {
        if (!isset($record['context']) || empty($record['context'])) {
            return $record;
        }

        $isDatabaseQueryContext = $this->arrayContainsOnlyNumericKeys($record['context']);
        if ($isDatabaseQueryContext) {
            $record['context'] = array('query params' => $record['context']);
        }

        return $record;
    }
738623
public void setRecord(Rec record)
    {
        if (m_tableNext != null)
            m_tableNext.setRecord(record);  // Must be synchronized
        super.setRecord(record);
    }
1188759
public function findExistingObject($record)
    {
        // checking for existing records (only if not already found)
        foreach ($this->duplicateChecks as $fieldName => $duplicateCheck) {
            //plain duplicate checks on fields and relations
            if (is_string($duplicateCheck)) {
                $fieldName = $duplicateCheck;
                //If the dupilcate check is a dot notation, then convert to ID relation
                if (strpos($duplicateCheck, '.') !== false) {
                    list($relationName, $columnName) = explode('.', $duplicateCheck);
                    $fieldName = $relationName."ID";
                }
                //TODO: also convert plain relation names to include ID

                //skip current duplicate check if field value is empty
                if (!isset($record[$fieldName]) || empty($record[$fieldName])) {
                    continue;
                }
                $existingRecord = $this->getDataList()
                                    ->filter($fieldName, $record[$fieldName])
                                    ->first();
                if ($existingRecord) {
                    return $existingRecord;
                }
            }
            //callback duplicate checks
            elseif (
                is_array($duplicateCheck) &&
                isset($duplicateCheck['callback']) &&
                is_callable($duplicateCheck['callback'])
            ) {
                $callback = $duplicateCheck['callback'];
                if ($existingRecord = $callback($fieldName, $record)) {
                    return $existingRecord;
                }
            } else {
                user_error('BulkLoader::processRecord(): Wrong format for $duplicateChecks',
                    E_USER_WARNING
                );
            }
        }

        return false;
    }
163658
protected function processChildRecord($record)
    {
        $id = (int)$record['uid'];
        $this->checkOptions($record);
        /* @var $recordContentObjectRenderer ContentObjectRenderer */
        $recordContentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class);
        $recordContentObjectRenderer->start($record, 'tt_content');
        $this->processedRecordVariables[$id] = ['data' => $record];
        if (
            (int)$this->options['recursive'] > 0 &&
            $record['CType'] === 'gridelements_pi1' &&
            !empty($record['tx_gridelements_backend_layout'])
        ) {
            $childProcessorConfiguration = $this->containerProcessorConfiguration;
            $childProcessorConfiguration['dataProcessing.']['0.'] = $this->processorConfiguration;
            $childProcessorConfiguration['dataProcessing.']['0.']['recursive'] = (int)$this->options['recursive'] - 1;
            $childProcessorConfiguration['dataProcessing.']['0'] = 'GridElementsTeam\Gridelements\DataProcessing\GridChildrenProcessor';
            $this->processedRecordVariables[$id] = $this->contentDataProcessor->process(
                $recordContentObjectRenderer,
                $childProcessorConfiguration,
                $this->processedRecordVariables[$id]
            );
        } else {
            $this->processedRecordVariables[$id] = $this->contentDataProcessor->process(
                $recordContentObjectRenderer,
                $this->containerProcessorConfiguration,
                $this->processedRecordVariables[$id]
            );
        }
    }
32017
protected static function create($record) {
        global $DB;
        if (empty($record->tagcollid)) {
            $record->tagcollid = core_tag_collection::get_default();
        }
        $DB->insert_record('tag_area', array('component' => $record->component,
            'itemtype' => $record->itemtype,
            'tagcollid' => $record->tagcollid,
            'callback' => $record->callback,
            'callbackfile' => $record->callbackfile,
            'showstandard' => isset($record->showstandard) ? $record->showstandard : core_tag_tag::BOTH_STANDARD_AND_NOT,
            'multiplecontexts' => isset($record->multiplecontexts) ? $record->multiplecontexts : 0));

        // Reset cache.
        cache::make('core', 'tags')->delete('tag_area');
    }
813201
public function validate(EntityInterface $record) {
        $fields = $this->getOption('fields');
        $sql = '1';
        $params = array();
        //Don't check the current object, so add a not on the primary keys
        $primaryKeys = $record->getModelsMetaData()->getPrimaryKeyAttributes($record);
        $columnMap = $record->getModelsMetaData()->getColumnMap($record);
        //Check to see if all of the values are still null
        $someValuesNotNull = false;
        foreach($primaryKeys as $i => $primaryKey) {
            $field = $columnMap[$primaryKey]; //Get shortened version
            $value = $record->readAttribute($field);
            if(!is_null($value)) {
                $someValuesNotNull = true;
            }
        }
        if($someValuesNotNull) {
            $sql .= ' AND NOT (';
            foreach($primaryKeys as $i => $primaryKey) {
                $field = $columnMap[$primaryKey]; //Get shortened version
                $value = $record->readAttribute($field);
                if($i != 0) {
                    $sql .= ' AND';
                }
                $paramKey = sizeOf($params);
                $sql .= ' ' . $field . '=?' . $paramKey;
                $params[] = $value;
            }
            $sql .= ')';
        }
        //Add each field
        foreach($fields as $field) {
            $paramKey = sizeOf($params);
            $value = $record->readAttribute($field);
            $sql .= ' AND ' . $field . '=?' . $paramKey;
            $params[] = $value;
        }
        /** @var ResultSet $resultSet */
        $resultSet = $record->find(
            [
                'conditions' => $sql,
                'bind' => $params,
                'limit' => 1
            ]
        );
        //If one is found, give an
        if($resultSet->count() == 0) {
            return true;
        } else {
            $this->appendMessage($this->getOption('message'));
            return false;
        }

    }
817858
public function add(RecordInterface $record): self
    {
        $this->assertValid($record);
        $this->loadData(true)->instances[] = $record;

        return $this;
    }
820902
public static function populateRecord($record, $row)
    {
        $dynCol = static::dynamicColumn();
        if (isset($row[$dynCol])) {
            $record->_dynamicAttributes = static::dynColDecode($row[$dynCol]);
        }
        parent::populateRecord($record, $row);
    }
955663
public function onLocalRecordsFirstRecord(Record $record, $records, $position, BaseRecords $baseRecords)
    {
        if (!$this->checkRecordPlugin($baseRecords)) {
            return;
        }

        $this->updater->setLocalRecord($record->getPlayer()->getNickname(), $record->getCheckpoints());
    }
823157
protected function write(Record $record)
    {
        $this->room->send(
            $this->getFormattedMessage($record),
            $this->from,
            $this->getLevelColor($record->getLevel()->getValue())
        );
    }
635072
public function update(Record $record, Entity $entity)
    {
        (new UpdateRecord($record, $entity, $this))->execute();

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

        return $document;
    }
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;
    }
183570
public function handle( Record $record )
    {
        $this->open( $record );

        if ($this->recordFormatter->formatRecord( $this->writer, $record )) {
            $this->incrementRecordCount();
        }

        return $record;
    }
135952
protected function validateRecord(array $record)
    {
        foreach ($this->validators as $name => $validator) {
            if (true !== $validator($record)) {
                throw CannotInsertRecord::triggerOnValidation($name, $record);
            }
        }
    }