Create a post entity from an stdClass (legacy post object).

@param stdClass $record The post record
@return post_entity
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
        );
    }
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;
  }
1205308
public function addRecord(\Gpupo\CommonSchema\ORM\Entity\Banking\Report\Record $record)
    {
        $this->records[] = $record;

        return $this;
    }
310268
public function fillRecordWithRelations(Record $record)
    {
        foreach ($this->getWith() as $relation) {
            $relation->fillRecord($record);
        }

        return $record;
    }
320301
public function storeRecord($currentTime, Record $record)
    {
        $id = $this->serializeRecordToIdentity($record);

        $cache = $this->cache;

        $this->cache
            ->get($id)
            ->then(
                function ($value) {
                    if ($value === null) {
                        // cache 0.5+ cache miss resolves with null, return empty bag here
                        return new RecordBag();
                    }

                    // reuse existing bag on cache hit to append new record to it
                    return unserialize($value);
                },
                function ($e) {
                    // legacy cache < 0.5 cache miss rejects promise, return empty bag here
                    return new RecordBag();
                }
            )
            ->then(function (RecordBag $recordBag) use ($id, $currentTime, $record, $cache) {
                // add a record to the existing (possibly empty) record bag and save to cache
                $recordBag->set($currentTime, $record);
                $cache->set($id, serialize($recordBag));
            });
    }
614666
private function detectRecord($record)
    {
        foreach ($this->recordTypes as $recordType) {
            $method = new ReflectionMethod($recordType, 'match');
            $arguments = [$record];

            if ($method->invokeArgs(null, $arguments) === false) {
                continue;
            }

            $class = $method->getDeclaringClass();

            return ($class->hasMethod('__construct'))
                ? $class->newInstanceArgs($arguments) : $class->newInstance();
        }

        throw new UnexpectedValueException();
    }
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;
    }
797489
public function removeRecord(\Gpupo\CommonSchema\ORM\Entity\Banking\Report\Record $record)
    {
        return $this->records->removeElement($record);
    }
1243015
final public function from_record(stdClass $record) {
        $record = (array) $record;
        foreach ($record as $property => $value) {
            $this->raw_set($property, $value);
        }
        return $this;
    }
443825
public function retrieve($record)
    {
        $params['index'] = $this->getName();
        $params['type'] = $record['type'];
        $params['id'] = $record['id'];

        self::getClient()->get($params);
    }
1292071
protected static function createInternal($record, $params = [])
    {
        $userId = SessionUtility::getCurrentUserId();
        $name = array_get($record, 'name');
        $modelExists = static::whereName($name)->whereUserId($userId)->first();
        if (!empty($modelExists)) {
            return $modelExists->updateInternal($modelExists->name, $record, $params);
        } else {
            $record['user_id'] = $userId;
            return parent::createInternal($record, $params);
        }
    }
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;
    }
1334317
protected static function _getRecordClass($record)
    {
        $static = get_called_class();

        if (!static::fieldExists('Class')) {
            return $static;
        }

        $columnName = static::_cn('Class');

        if (!empty($record[$columnName]) && is_subclass_of($record[$columnName], $static)) {
            return $record[$columnName];
        } else {
            return $static;
        }
    }
183570
public function handle( Record $record )
    {
        $this->open( $record );

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

        return $record;
    }
354170
public function postIdOfPostupdate($id)
    {
        // $record is a stdClass
        $record = DB::table('postupdates')
            ->select('post_id')
            ->where('id', '=', $id)
            ->first()
        ;

        return $record->post_id;
    }
1013090
public static function fromRecord($record)
    {
        if (!$record) {
            return null;
        }
        $className = get_called_class();
        $entity = new $className;
        foreach ($record as $key => $value) {
            $entity->$key = $value;
        }
        return $entity;
    }
909032
public function updateRecord(GedcomRecord $record): string
    {
        $old_gedcom = $record->gedcom();

        $new_gedcom = preg_replace([
            '/(\n1.*@.+@.*(?:(?:\n[2-9].*)*))((?:\n1.*(?:\n[2-9].*)*)*\1)/',
            '/(\n2.*@.+@.*(?:(?:\n[3-9].*)*))((?:\n2.*(?:\n[3-9].*)*)*\1)/',
            '/(\n3.*@.+@.*(?:(?:\n[4-9].*)*))((?:\n3.*(?:\n[4-9].*)*)*\1)/',
        ], '$2', $old_gedcom);

        return $new_gedcom;
    }