Gets the next session in the queue, clearing out any which are expired.

@param array $data
@return array|null
163586
private function getSession(array &$data)
    {
        $session = array_shift($data['queue']);

        if ($session) {
            if ($session['expiration'] - self::DURATION_ONE_MINUTE < $this->time()) {
                return $this->getSession($data);
            }

            $data['inUse'][$session['name']] = $session + [
                'lastActive' => $this->time()
            ];

            if ($this->config['shouldAutoDownsize']) {
                $this->manageSessionsToDelete($data);
            }
        }

        return $session;
    }
842042
private function getUpdateQuery(array $data)
    {
        //This is a hack to prevent parameters being mixed up.
        $tempParameters   = $this->parameters;
        $this->parameters = [];

        $query = $this->applyFilters(
            $this->queryBuilder
                ->update($this->entity->getTable())
                ->values($this->parameters($data))
        );

        $this->parameters = array_merge($this->parameters, $tempParameters);

        return $query;
    }
1096097
private static function getObjectFromArray($data): self
    {
        if (!isset($data['last_access'])) {
            $lastAccess = null;
        } else {
            $lastAccess = new \DateTime($data['last_access']);
        }

        return new self(
            $data['user_id'],
            $data['organization_id'],
            $data['roles'],
            $data['active'],
            $lastAccess
        );
    }
1071031
public function offsetGet ($offset) {
		$data = & $_SESSION[$this->__name];
        return isset($data[$offset]) ? $data[$offset] : NULL;
    }
558983
protected final function getWhere($data) {
        $con = [];
        foreach ($this->primaryKeys as $f) {
            if (array_key_exists($f, $data)) {
                if (isset($data[ $f ])) {
                    $con [ $f ] = $data [ $f ];
                } else {
                    $con [ $f . ' $' ] = null;
                }
            }
        }

        return $con;
    }
1027031
public function remove($data)
    {
        if (is_array($data)) {
            foreach ($data as $entity) {
                $this
                    ->manager
                    ->remove($entity);
            }
        } else {
            $this
                ->manager
                ->remove($data);
        }

        $this
            ->manager
            ->flush($data);

        return $data;
    }
236990
private function manageSessionsToDelete(array &$data)
    {
        $secondsSinceLastWindow = $this->time() - $data['windowStart'];
        $inUseCount = count($data['inUse']);

        if ($secondsSinceLastWindow < self::WINDOW_SIZE + 1) {
            if ($data['maxInUseSessions'] < $inUseCount) {
                $data['maxInUseSessions'] = $inUseCount;
            }

            return;
        }

        $totalCount = $inUseCount + count($data['queue']) + count($data['toCreate']);
        $windowsPassed = (int) ($secondsSinceLastWindow / self::WINDOW_SIZE);
        $deletionCount = min(
            $totalCount - (int) round($data['maxInUseSessions'] / $windowsPassed),
            $totalCount - $this->config['minSessions']
        );
        $data['maxInUseSessions'] = $inUseCount;
        $data['windowStart'] = $this->time();

        if ($deletionCount) {
            $this->deleteQueue += array_splice(
                $data['queue'],
                (int) -$deletionCount
            );
        }
    }
1212338
public function get(string $key)
    {
        if (isset($this->ttl[$key]) && 0 !== $this->ttl[$key]) {
            $this->expire[$key] = time() + $this->ttl[$key];
            $this->queue->insert($key, -$this->expire[$key]);
        }

        return isset($this->data[$key]) ? $this->data[$key] : null;
    }
906729
public function whereExists(array $data)
    {
        $this->parseConstraints($data);

        $query = $this->connection->getPdo()->prepare($this->getSelectQuery());

        return $this->execute($query)->fetch();
    }
533660
protected function getNext()
    {
        if (!$this->current)
        {
            return null;
        }
        if ($this->next !== -1)
        {
            return $this->next;
        }
        $this->load();
        for ($i = 0; $i < count($this->items); $i++)
        {
            if ($this->items[$i]->id == $this->current->id)
            {
                if ($i + 1 < count($this->items))
                {
                    $this->next = $this->items[$i + 1];
                    return $this->next;
                }
                break;
            }
        }
        return null;
    }
972141
private function order(array $data)
    {
        $filteredData = $this->filterOrderable($data);

        if (!empty($filteredData)) {
            uasort(
                $filteredData,
                function (OrderedNormalizerInterface $a, OrderedNormalizerInterface $b) {
                    return $a->getOrder() > $b->getOrder();
                }
            );

            return array_merge($filteredData, array_diff_key($data, $filteredData));
        }

        return $data;
    }
337739
public function setCache(array $data)
    {
        if (!$this->isCached) {
            $this->memcache->set(
                $this->config['key_prefix'] . '.storage',
                $data,
                false,
                $this->config['expiration_time']
            );
        }

        return $this;
    }
209526
public function setCache(array $data)
    {
        $handle = $this->handle;

        $rows = $handle->query('SELECT created FROM `' . $this->config['table'].'`');

        if (!$rows || $rows->rowCount() === 0) {

            $this->write($handle, $data);
        } else {

            foreach ($rows as $row) {

                if ((time()-strtotime($row['created'])) >
                    $this->config['expiration_time']) {

                    $this->write($handle, $data);
                }
            }
        }

        return $this;
    }
1184154
public function execute($data = null)
    {
        $result = $this->next->execute($data);

        $response = $data->response;

        $this->controller->setResponse(new RedirectResponse(
            $result,
            $response->getStatusCode(),
            $response->getHeaders()
        ));

        return $this->next->execute($data);
    }
569039
private function convertData(array $data = null)
    {
        if (!is_array($data)) {
            return $data;
        }

        foreach ($data as $key => $val) {
            /** convert dbrefs */
            if (is_array($val) && isset($val['$ref']) && isset($val['$id'])) {
                $data[$key] = $this->convertData(
                    $this->resolveObject($val['$ref'], $val['$id'])
                );
            } elseif (is_array($val)) {
                $data[$key] = $this->convertData($val);
            }
            /** convert mongodate to text dates **/
            if ($val instanceof \MongoDate) {
                $data[$key] = $this->dateConverter->formatDateTime($val->toDateTime());
            }
            /** convert mongoid */
            if ($val instanceof \MongoId) {
                $data[$key] = (string) $val;
            }
        }

        return $data;
    }
1297999
private function getTimeObjects(array $data) {
    $date = \DateTime::createFromFormat(
      self::API_DATE_FORMAT,
      $data['date'],
      new \DateTimeZone(self::API_TIMEZONE)
    );

    $sourceTimes = explode('-', $data['time']);

    $sourceTimeStart = date_parse($sourceTimes[0]);
    if (!$sourceTimeStart) {
      throw new \Exception(sprintf('Failed to parse time %s', $sourceTimes[0]));
    }

    $sourceTimeEnd = date_parse($sourceTimes[1]);
    if (!$sourceTimeEnd) {
      throw new \Exception(sprintf('Failed to parse time %s', $sourceTimes[1]));
    }

    $dateStart = clone($date);
    $dateEnd = clone($date);

    $dateStart->setTime($sourceTimeStart['hour'], $sourceTimeStart['minute']);
    $dateEnd->setTime($sourceTimeEnd['hour'], $sourceTimeEnd['minute']);

    return [
      'start' => $dateStart,
      'end' => $dateEnd,
    ];
  }
732382
public function filter(array $data)
    {
        $filteredData = [];

        foreach ($data as $value) {
            if ($this->match($value)) {
                $filteredData[] = $value;
            }
        }

        return $filteredData;
    }