@param array $records

@return mixed
543337
protected static function mongoIdsToIds($records)
    {
        foreach ($records as $key => $record) {
            $records[$key] = static::mongoIdToId($record);
        }

        return $records;
    }
196563
public static function get_records($filters = array(), $sort = '', $order = 'ASC', $skip = 0, $limit = 0) {
        global $DB;

        $orderby = '';
        if (!empty($sort)) {
            $orderby = $sort . ' ' . $order;
        }

        $records = $DB->get_records(static::TABLE, $filters, $orderby, '*', $skip, $limit);
        $instances = array();

        foreach ($records as $record) {
            $newrecord = new static(0, $record);
            array_push($instances, $newrecord);
        }
        return $instances;
    }
792332
public static function translateKeys($records, $translations)
    {
        if (!self::iterable($records)) {
            return array();
        }
        
        $out = array();
        foreach ($records as $n => $record) {
            if (!self::iterable($record)) {
                $out[$n] = $record;
                continue;
            }
            $out[$n] = array();
            
            foreach ($record as $k => $v) {
                $new_k = (array_key_exists($k, $translations)) ? $translations[$k] : $k;
                $out[$n][$new_k] = $v;
            }
        }
        return $out;
    }
989395
public function format(array $record)
    {
        $data = parent::format($record);
        return $this->toJson($data, true);
    }
1297470
private function recordFilter(array $records)
    {
        $messages = [];
        foreach ($records as $record) {
            if (!isset($record['level'])) {
                continue;
            }
            if (!$this->isHandling($record)) {
                continue;
            }

            $record = $this->processRecord($record);
            $record['formatted'] = $this->getFormatter()->format($record);

            $messages[] = $record;
        }
        return $messages;
    }
1055366
public function handleBatch(array $records)
    {
        $records = $this->recordFilter($records);
        if (empty($records)) {
            return true;
        }

        $lines = array_column($records, 'formatted');

        $this->write($lines);
    }
649072
public function createMany(array $records, array $properties = array())
    {
        $instances = new Collection;

        foreach ($records as $record)
        {
            $instances->push($this->create($record, $properties));
        }

        return $instances;
    }
557839
private function findRecord(array $records, string $domain, string $name, string $type): ?Record
    {
        foreach ($records as $record) {
            if (
                $domain === $record->getDomain() &&
                $name === $record->getName() &&
                $type === $record->getType()
            ) {
                return $record;
            }
        }

        return null;
    }
609692
protected function transform_db_records_to_entities(array $records) {
        $preprocessors = $this->get_preprocessors();
        $result = array_map(function($record) {
            return ['record' => $record];
        }, $records);

        $result = array_reduce(array_keys($preprocessors), function($carry, $preprocessor) use ($records, $preprocessors) {
            $step = $preprocessors[$preprocessor];
            $dependencies = $step->execute($records);

            foreach ($dependencies as $index => $dependency) {
                // Add the new dependency to the list.
                $carry[$index] = array_merge($carry[$index], [$preprocessor => $dependency]);
            }

            return $carry;
        }, $result);

        return $this->from_db_records($result);
    }
622795
public function write($records)
    {
        // Array for tracking successfully harvested IDs:
        $harvestedIds = [];

        // Date of most recent record encountered:
        $endDate = 0;

        $this->strategy->beginWrite();

        // Loop through the records:
        foreach ($records as $record) {
            // Die if the record is missing its header:
            if (empty($record->header)) {
                throw new \Exception('Unexpected missing record header.');
            }

            // Get the ID of the current record:
            $id = $this->extractID($record);

            // Save the current record, either as a deleted or as a regular file:
            $attribs = $record->header->attributes();
            if (strtolower($attribs['status']) == 'deleted') {
                $this->strategy->addDeletedRecord($id);
            } else {
                $recordXML = $this->recordFormatter->format($id, $record);
                $this->strategy->addRecord($id, $recordXML);
                $harvestedIds[] = $id;
            }

            // If the current record's date is newer than the previous end date,
            // remember it for future reference:
            $date = $this->normalizeDate($record->header->datestamp);
            if ($date && $date > $endDate) {
                $endDate = $date;
            }
        }

        $this->strategy->endWrite();

        $this->writeHarvestedIdsLog($harvestedIds);

        return $endDate;
    }
762668
public function groupRecords($records)
    {
        if (!is_array($records) || empty($records)) {
            return;
        }

        $groups = array('year' => array());

        foreach ($records as $r) {
            $data = $r->getData($this->get('id'));

            $timestamp = DateTimeObj::get('U', $data['value']);
            $info = getdate($timestamp);

            $year = $info['year'];
            $month = ($info['mon'] < 10 ? '0' . $info['mon'] : $info['mon']);

            if (!isset($groups['year'][$year])) {
                $groups['year'][$year] = array(
                    'attr' => array('value' => $year),
                    'records' => array(),
                    'groups' => array()
                );
            }

            if (!isset($groups['year'][$year]['groups']['month'])) {
                $groups['year'][$year]['groups']['month'] = array();
            }

            if (!isset($groups['year'][$year]['groups']['month'][$month])) {
                $groups['year'][$year]['groups']['month'][$month] = array(
                    'attr' => array('value' => $month),
                    'records' => array(),
                    'groups' => array()
                );
            }

            $groups['year'][$year]['groups']['month'][$month]['records'][] = $r;
        }

        return $groups;
    }
594316
public function saveRecords(array $records, DataDimensions $dataDimensions = null)
    {

        if (count($records) > 0) {
            if (!$dataDimensions) {
                $dataDimensions = $this->getCurrentDataDimensions();
            }
            unset($this->repositoryInfo[(string)$dataDimensions]);

            $record = reset($records);

            foreach ($records as $record) {
                $record = $record->setLastChangeUserInfo($this->userInfo);
                $this->stashRecord($record, $dataDimensions);
            }

            $url = 'content/' . $record->getContentTypeName() . '/records/' . $dataDimensions->getWorkspace() . '/' . $dataDimensions->getViewName();

            $this->getClient()->setDefaultOption('query',
                [
                    'userinfo' => [
                        'username'  => $this->userInfo->getUsername(),
                        'firstname' => $this->userInfo->getFirstname(),
                        'lastname'  => $this->userInfo->getLastname()
                    ]
                ]);

            $response = $this->getClient()
                ->post($url, [
                    'body' => [
                        'records'  => json_encode($records),
                        'language' => $dataDimensions->getLanguage()
                    ]
                ]);

            return $response->json();
        }

        return [];
    }
163841
final public static function instantiate (array $record)
	{
		$className 	= get_called_class();
		$object 	= new $className;
		foreach ($record as $attribute => $value):
			$object->$attribute = $value;
		endforeach;
		return $object;
	}
786494
protected function from_db_records(array $results) {
        $entityfactory = $this->get_entity_factory();
        $records = array_map(function($result) {
            return $result['record'];
        }, $results);

        return $entityfactory->get_post_read_receipt_collection_from_stdclasses($records);
    }
791222
public function format(array $record)
    {
        $jsonString = json_encode($this->getOutputRecord($record));

        if ($jsonString === false) {
            throw new \RuntimeException('Error happened during the log format process! (json encode error)');
        }

        return $jsonString . PHP_EOL;
    }
135314
public function transformRecords($records)
    {
        if (method_exists($this->class, 'laratablesModifyCollection')) {
            $records = $this->class::laratablesModifyCollection($records)->values();
        }

        return $records->map(function ($item) {
            return $this->transformRecord($item);
        });
    }
1112894
public function getSpecificIds(array $record)
    {
        $specificIds = [];
        $specificIds['uid'] = (int)$record['uid'];
        $specificIds['pid'] = (int)$record['pid'];

        if (self::getBackendUser()->workspace > 0 && !empty($record['t3ver_oid'])) {
            $specificIds['uid'] = (int)$record['t3ver_oid'];
            $specificIds['pid'] = -1;
        }

        return $specificIds;
    }