Skip to content

Commit 044efbd

Browse files
author
Dave MacFarlane
committed
[meta] Remove deprecated functions from Utility.class.inc
There are a number of functions in Utility.class.inc that have been there for years. get??Instruments have printed a deprecation warning for 4 years. Other methods have been throwing exceptions. It's time to remove them.
1 parent 6ea4c12 commit 044efbd

File tree

1 file changed

+0
-156
lines changed

1 file changed

+0
-156
lines changed

php/libraries/Utility.class.inc

Lines changed: 0 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -211,29 +211,6 @@ class Utility
211211
);
212212
}
213213

214-
/**
215-
* Get the list of sites as an associative array
216-
*
217-
* @param boolean $study_site if true only return study sites from psc
218-
* table
219-
* @param boolean $DCC Whether the DCC should be included or not
220-
*
221-
* @return array of the form CenterID => Site Name.
222-
* Note that even though CenterID is numeric, the array
223-
* should be interpreted as an associative array since the keys
224-
* refer to the centerID, not the array index.
225-
*
226-
* @deprecated
227-
*/
228-
static function getAssociativeSiteList(
229-
bool $study_site = true,
230-
bool $DCC = true
231-
): array {
232-
throw new \DeprecatedException(
233-
' This function is deprecated. Please use \Utility::getSiteList()'
234-
. ' instead.'
235-
);
236-
}
237214

238215
/**
239216
* Returns a list of study Visit Labels that are being used by this study.
@@ -468,30 +445,6 @@ class Utility
468445
return $associative_array;
469446
}
470447

471-
/**
472-
* Ensures that $var is a collection of $var elements, not just a
473-
* single element. This is useful for using config->getSetting for an element
474-
* that may be in the config multiple times or may be in the config file a
475-
* single time. By calling toArray, you ensure that the value you're working
476-
* with is an array and don't need to determine if it's an array or a scalar.
477-
* Note: This does not change a string into an array with one string element
478-
* Note: This function should be used for tags with attributes
479-
*
480-
* @param mixed $var The variable to be converted to an array.
481-
*
482-
* @return array If $var is an array, var, otherwise an array containing $var
483-
*
484-
* @deprecated
485-
*/
486-
static function toArray($var)
487-
{
488-
throw new \DeprecatedException(
489-
'Utility::toArray() is deprecated and should not be used. ' .
490-
'Instead use Utility::associativeToNumericArray() for converting ' .
491-
'arrays. Scalar values cannot be passed to this function.'
492-
);
493-
}
494-
495448
/**
496449
* Takes a scalar value and returns an array containing that value as its
497450
* only element.
@@ -537,96 +490,6 @@ class Utility
537490
return $arr;
538491
}
539492

540-
/**
541-
* Get a list of instruments installed in Loris.
542-
*
543-
* @return array of the form Test_name => Full Description
544-
*/
545-
static function getAllInstruments(): array
546-
{
547-
error_log(
548-
"LORIS Deprecation Warning: The getAllInstruments() function of ".
549-
"the Utility class has been deprecated. This function does not load ".
550-
"the most accurate Full_name value and should be replaced by ".
551-
"getInstrumentNamesList() of the NDB_BVL_Instrument class."
552-
);
553-
$Factory = \NDB_Factory::singleton();
554-
$DB = $Factory->Database();
555-
$instruments_q = $DB->pselect(
556-
"SELECT Test_name,Full_name FROM test_names ORDER BY Full_name",
557-
[]
558-
);
559-
$instruments = [];
560-
foreach ($instruments_q as $row) {
561-
if (isset($row['Test_name']) && isset($row['Full_name'])) {
562-
$instruments[$row['Test_name']] =$row['Full_name'];
563-
}
564-
}
565-
566-
return $instruments;
567-
}
568-
569-
/**
570-
* Get a list of DDE instruments installed in Loris.
571-
*
572-
* @return array of the form Test_name => Full Description
573-
*/
574-
static function getAllDDEInstruments(): array
575-
{
576-
error_log(
577-
"LORIS Deprecation Warning: The getAllDDEInstruments() function of
578-
the Utility class has been deprecated. This function does not load the
579-
most accurate Full_name value and should be replaced by
580-
getDDEInstrumentNamesList() of the NDB_BVL_Instrument class."
581-
);
582-
$Factory = \NDB_Factory::singleton();
583-
$DB = $Factory->Database();
584-
$ddeInstruments = $DB->pselect(
585-
"SELECT DISTINCT test_battery.Test_name, Full_name
586-
FROM test_battery
587-
JOIN test_names ON test_battery.Test_name = test_names.Test_name
588-
WHERE DoubleDataEntryEnabled = 'Y'",
589-
[]
590-
);
591-
$instruments = [];
592-
foreach ($ddeInstruments as $instrument) {
593-
$instruments[$instrument['Test_name']] = $instrument['Full_name'];
594-
}
595-
return $instruments;
596-
}
597-
598-
/**
599-
* Gets a list of all instruments where are administered as direct data
600-
* entry from subjects.
601-
* This should return an array in a format suitable for addSelect() from
602-
* NDB_Page
603-
*
604-
* @return array of test_names in a Test_Name => "Full Name"
605-
*/
606-
static function getDirectInstruments(): array
607-
{
608-
error_log(
609-
"LORIS Deprecation Warning: The getDirectInstruments() function of
610-
the Utility class has been deprecated. This function does not load the
611-
most accurate Full_name value and should be replaced by
612-
getDirectEntryInstrumentNamesList() of the NDB_BVL_Instrument class."
613-
);
614-
$factory = NDB_Factory::singleton();
615-
$DB = $factory->database();
616-
617-
$instruments = [];
618-
$instruments_q = $DB->pselect(
619-
"SELECT Test_name,Full_name FROM test_names WHERE IsDirectEntry=true
620-
ORDER BY Full_name",
621-
[]
622-
);
623-
foreach ($instruments_q as $key) {
624-
$instruments[$key['Test_name']] =$key['Full_name'];
625-
}
626-
627-
return $instruments;
628-
}
629-
630493
/**
631494
* Checks to see if a table contains a specified column
632495
*
@@ -737,25 +600,6 @@ class Utility
737600
return iterator_to_array($sourcefields);
738601
}
739602

740-
/**
741-
* Returns a list of study Visit Labels that are being used by this study.
742-
*
743-
* @param integer|null $projectID Limit visit labels to labels used by this
744-
* project.
745-
*
746-
* @return array<string,string> Study visits in the format array('VL' => 'VL')
747-
* where VL is the visit label
748-
*
749-
* @deprecated
750-
*/
751-
static function getExistingVisitLabels(?int $projectID = null): array
752-
{
753-
throw new \DeprecatedException(
754-
'This function is deprecated. Please use Utility::getVisitList() '
755-
. 'instead.'
756-
);
757-
}
758-
759603
/**
760604
* Get all the instruments which currently exist for a given visit label
761605
* in the database.

0 commit comments

Comments
 (0)