/** * Gets the list of projects within environment * * @param int $envId Identifier of the Environment * @return array Returns array of the ProjectEntity objects */ public function getUsedInEnvironment($envId) { $projectIds = $this->db->GetCol("\n SELECT DISTINCT s.value FROM farms f\n JOIN farm_settings s ON s.farmid = f.id AND s.name = ?\n WHERE f.env_id = ? AND s.value != ''\n ", [Entity\FarmSetting::PROJECT_ID, $envId]); return $projectIds ? ProjectEntity::find([['projectId' => ['$in' => $projectIds]]]) : []; }