Skip to content
Snippets Groups Projects
Commit 76eda282 authored by Kevin Abel's avatar Kevin Abel
Browse files

Use the SubjectAreas class as the source for subject codes

parent 5ac2b1a7
Branches
Tags
No related merge requests found
......@@ -3,17 +3,28 @@ namespace UNL\Catalog;
class SubjectAreas extends \ArrayIterator
{
function __construct($options = array())
/**
* Returns an array with subject code keys and title values
*
* @throws Exception
* @return array
*/
public static function getMap()
{
$this->options = $options;
$mapping = file_get_contents(Controller::getDataDir().'/creq/subject_codes.php.ser');
$mapping = file_get_contents(Controller::getCourseDataDir() . '/subject_codes.php.ser');
if (false === ($mapping = unserialize($mapping))) {
throw new Exception('Invalid major to subject code matching file.', 500);
}
parent::__construct($mapping);
return $mapping;
}
function __construct($options = array())
{
$this->options = $options;
parent::__construct(self::getMap());
}
function getCacheKey()
......@@ -33,18 +44,12 @@ class SubjectAreas extends \ArrayIterator
function current()
{
$options = array('subjectArea' => $this->key(),
$options = array(
'subjectArea' => $this->key(),
'title' => parent::current(),
);
try {
$area = new SubjectArea($options);
} catch(Exception $e) {
throw new Exception(
'Error in ' . $this->getFilename().':'
. ' subject area id "'.$data[0].'" with title "'.$data[1].'" is invalid.'
, 500, $e);
}
return $area;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment