if (empty($this->AllowedMethods)) { $this->AllowedMethods = ['GET']; } $requestDelegationCascade = $this->AutoHandleRequestDelegation; // Parent will validate CandID and Visit Label and abort if necessary parent::__construct($method, $CandID, $Visit); if ($requestDelegationCascade) { $this->handleRequest(); } } /** * Handles a GET request for this API call. * * @return none, but populates $this->JSON */ public function handleGET() { $Insts = $this->DB->pselect("SELECT DISTINCT Test_name" . " FROM flag f" . " JOIN session s ON (s.ID=f.SessionID)" . " WHERE s.CandID=:CID AND s.Active='Y' AND s.Visit_label=:VL", array('CID' => $this->CandID, 'VL' => $this->VisitLabel)); //array_column only exists in PHP 5.5+, need to use array_map //until we no longer support 5.4.. //$Instruments = array_column($Insts, 'Test_name'); $Instruments = array_map(function ($element) { return $element['Test_name']; }, $Insts); $this->JSON = ["Meta" => ["CandID" => $this->CandID, 'Visit' => $this->VisitLabel], 'Instruments' => $Instruments]; } } if (isset($_REQUEST['PrintInstruments'])) { $obj = new Instruments($_SERVER['REQUEST_METHOD'], $_REQUEST['CandID'], $_REQUEST['VisitLabel']); print $obj->toJSONString(); }