aboutsummaryrefslogtreecommitdiff
path: root/lib/models/eTask/Task.php
diff options
context:
space:
mode:
authorElmar Ludwig <elmar.ludwig@uni-osnabrueck.de>2022-09-19 11:44:55 +0000
committerElmar Ludwig <elmar.ludwig@uni-osnabrueck.de>2022-09-19 11:44:55 +0000
commit3a9652b27823219e533cef1f111183f8ef378d50 (patch)
treec442ec2a309b5c3c11d528a9d0a8e28a81d0bd93 /lib/models/eTask/Task.php
parentd3f79db0041193160190694d731ba00929d6f871 (diff)
use class configuration instead of `$this->relationTypes`, re #1473
Merge request studip/studip!1018
Diffstat (limited to 'lib/models/eTask/Task.php')
-rw-r--r--lib/models/eTask/Task.php25
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/models/eTask/Task.php b/lib/models/eTask/Task.php
index 68d4a20..989915d 100644
--- a/lib/models/eTask/Task.php
+++ b/lib/models/eTask/Task.php
@@ -39,7 +39,13 @@ class Task extends \SimpleORMap implements \PrivacyObject
'foreign_key' => 'user_id'
];
- $config['additional_fields']['tests']['get'] = 'getTests';
+ $config['has_and_belongs_to_many']['tests'] = [
+ 'class_name' => $config['relationTypes']['Test'],
+ 'assoc_foreign_key' => 'id',
+ 'thru_table' => 'etask_test_tasks',
+ 'thru_key' => 'task_id',
+ 'thru_assoc_key' => 'test_id'
+ ];
$config['has_many']['test_tasks'] = [
'class_name' => $config['relationTypes']['TestTask'],
@@ -63,25 +69,14 @@ class Task extends \SimpleORMap implements \PrivacyObject
/**
* Retrieve the tests associated to this task.
+ * @deprecated - use $this->tests instead.
*
* @return SimpleORMapCollection the associated tests
*/
public function getTests()
{
- $klass = $this->relationTypes['Test'];
-
- return \SimpleORMapCollection::createFromArray(
- $klass::findThru(
- $this->id,
- [
- 'thru_table' => 'etask_test_tasks',
- 'thru_key' => 'task_id',
- 'thru_assoc_key' => 'test_id',
- 'assoc_foreign_key' => 'id',
- 'order_by' => 'ORDER BY etask_tests.chdate ASC'
- ]
- )
- );
+ $this->initRelation('tests');
+ return $this->relations['tests'];
}
/**