/** * @param $current_date * @return null */ public function getActives($current_date = null) { $services = array(); $ordering_set = false; $prefix = get_class($this); $order = $this->cache_service->getSingleValue(strtolower($prefix . ".ordering")); if (!empty($order)) { $service_count = $this->repository->countActives(); if (intval($service_count) != count(explode(',', $order))) { //select random order $services = $this->repository->getActivesRandom(); } else { $ordering_set = true; $services = $this->repository->getActivesByList($order); } } else { $services = $this->repository->getActivesRandom(); } if (count($services)) { $ordering = array(); $to_remove = array(); foreach ($services as $s) { if (!is_null($this->show_policy) && !$this->show_policy->canShow($s->getIdentifier())) { array_push($to_remove, $s); } array_push($ordering, $s->getIdentifier()); } $services = array_diff($services, $to_remove); if (!$ordering_set) { $this->cache_service->setSingleValue(strtolower($prefix . ".ordering"), implode(', ', $ordering)); } } return $services; }