appKey = $appKey; $this->appbox = $appbox; $this->acl = $acl; } /** * @param $table * @param null $sbasId * @param null $parms * * @return ReportConnections | ReportActions */ public function createReport($table, $sbasId=null, $parms=null) { switch($table) { case self::CONNECTIONS: return (new ReportConnections( $this->findDbOr404($sbasId), $parms )) ->setAppKey($this->appKey) ; break; case self::DOWNLOADS: return (new ReportActions( $this->findDbOr404($sbasId), $parms )) ->setAppKey($this->appKey) ->setACL($this->acl) ->setAsDownloadReport(true) ; break; case self::RECORDS: return (new ReportRecords( $this->findDbOr404($sbasId), $parms )) ->setACL($this->acl) ; break; default: throw new \InvalidArgumentException(sprintf("unknown table type \"%s\"", $table)); break; } } /** * @param int $sbasId * @return \databox */ private function findDbOr404($sbasId) { $db = $this->appbox->get_databox(($sbasId)); if(!$db) { throw new NotFoundHttpException(sprintf('Databox %s not found', $sbasId)); } return $db; } }