/** * Ensures profile series data is up to date, according to configured update interval * * @param UserProfile $profile * * @return UserProfile $profile */ private function updateSeriesData($profile) { $paramFields = array(); $now = new \DateTime(); foreach ($profile->getValues() as $value) { $nowCheck = clone $now; $field = $value->getUserProfileField(); // If profile is new or is being checked past updateInterval time, and field is series and enabled, do the thing if (($value->getTimeLastEdited() < $nowCheck->modify('-' . $this->updateInterval) || $value->getTimeLastEdited() < $profile->getTimeCreated()->modify('+10 seconds')) && $field->isSeries() && $field->getEnabled()) { $paramFields[] = $field->getName(); } } if (count($paramFields)) { // Hit the configured service to get the data $data = $this->userDataHelper['service']->{$this->userDataHelper['method']}($profile->getUser(), $paramFields, $this->reportingIntervals); $this->setProfileValues($profile, $data); } }