Skip to content
Snippets Groups Projects
Commit ccc24573 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by Jan-Hendrik Willms
Browse files

fix errors in mvv models, fixes #1230

Closes #1230

Merge request studip/studip!741
parent 0643fdef
No related branches found
No related tags found
No related merge requests found
<?php
/**
* This interface ensures that all objects of ModuleManagementModel have
* the same constructor signature. Otherwise, we can not guarantee that the
* use of "new static()" in ModuleManagement code will always do the right
* things.
*
* @author Jan-Hendrik Willms <tleilax+studip@gmail.com>
* @license GPL2 or any later version
*/
interface ModuleManagementInterface
{
public function __construct($id = null);
}
...@@ -364,7 +364,7 @@ class Lvgruppe extends ModuleManagementModelTreeItem ...@@ -364,7 +364,7 @@ class Lvgruppe extends ModuleManagementModelTreeItem
*/ */
public function getTrailParent() public function getTrailParent()
{ {
return Modul::findCached($this->getTrailParent_id()); return Modul::findCached($this->getTrailParentId());
} }
/** /**
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
require_once 'config/mvv_config.php'; require_once 'config/mvv_config.php';
abstract class ModuleManagementModel extends SimpleORMap abstract class ModuleManagementModel extends SimpleORMap implements ModuleManagementInterface
{ {
/** /**
* Usable as option for ModuleManagementModel::getDisplayName(). * Usable as option for ModuleManagementModel::getDisplayName().
...@@ -133,7 +133,7 @@ abstract class ModuleManagementModel extends SimpleORMap ...@@ -133,7 +133,7 @@ abstract class ModuleManagementModel extends SimpleORMap
/** /**
* Returns an object by given id with all relations and additional fields. * Returns an object by given id with all relations and additional fields.
* *
* @param tring $id The id of the object. * @param string $id The id of the object.
* @return ModuleManagementModel * @return ModuleManagementModel
*/ */
public static function getEnriched($id) public static function getEnriched($id)
...@@ -493,7 +493,7 @@ abstract class ModuleManagementModel extends SimpleORMap ...@@ -493,7 +493,7 @@ abstract class ModuleManagementModel extends SimpleORMap
* @param array $params Array with the parameters used in query * @param array $params Array with the parameters used in query
* @param int $row_count Number of rows to return * @param int $row_count Number of rows to return
* @param int $offset Offset where the result set starts * @param int $offset Offset where the result set starts
* @return object SimpleOrMapCollection with all found objects or empty array * @return SimpleOrMapCollection with all found objects or empty array
*/ */
public static function getEnrichedByQuery($query = null, $params = [], public static function getEnrichedByQuery($query = null, $params = [],
$row_count = null, $offset = null) $row_count = null, $offset = null)
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
* @since 3.5 * @since 3.5
*/ */
require_once 'ModuleManagementModel.php';
abstract class ModuleManagementModelTreeItem extends ModuleManagementModel implements MvvTreeItem abstract class ModuleManagementModelTreeItem extends ModuleManagementModel implements MvvTreeItem
{ {
/** /**
......
...@@ -99,7 +99,7 @@ class Modulteil extends ModuleManagementModelTreeItem ...@@ -99,7 +99,7 @@ class Modulteil extends ModuleManagementModelTreeItem
/** /**
* Retrieves all Modulteile of the given Modul. * Retrieves all Modulteile of the given Modul.
* *
* @param type $modul_id The id of a Modul. * @param string $modul_id The id of a Modul.
* @return SimpleORMapCollection A collection of Modulteile. * @return SimpleORMapCollection A collection of Modulteile.
*/ */
public static function findByModul($modul_id) public static function findByModul($modul_id)
...@@ -119,7 +119,7 @@ class Modulteil extends ModuleManagementModelTreeItem ...@@ -119,7 +119,7 @@ class Modulteil extends ModuleManagementModelTreeItem
/** /**
* Retrieves all Modulteile the given LV-Gruppe is assigned to. * Retrieves all Modulteile the given LV-Gruppe is assigned to.
* *
* @param type $lvgruppe_id The id of a LV-Gruppe. * @param string $lvgruppe_id The id of a LV-Gruppe.
* @return SimpleORMapCollection A collection of Modulteile. * @return SimpleORMapCollection A collection of Modulteile.
*/ */
public static function findByLvgruppe($lvgruppe_id) public static function findByLvgruppe($lvgruppe_id)
......
...@@ -37,7 +37,7 @@ class MvvCourse extends ModuleManagementModelTreeItem ...@@ -37,7 +37,7 @@ class MvvCourse extends ModuleManagementModelTreeItem
*/ */
public function getTrailParent() public function getTrailParent()
{ {
return LvGruppe::findCached($this->getTrailParent_id()); return LvGruppe::findCached($this->getTrailParentId());
} }
/** /**
...@@ -58,7 +58,7 @@ class MvvCourse extends ModuleManagementModelTreeItem ...@@ -58,7 +58,7 @@ class MvvCourse extends ModuleManagementModelTreeItem
public function getDisplayName($options = self::DISPLAY_DEFAULT) public function getDisplayName($options = self::DISPLAY_DEFAULT)
{ {
$this->getName(); return $this->name;
} }
/** /**
......
...@@ -44,12 +44,14 @@ class MvvFileFileref extends ModuleManagementModel ...@@ -44,12 +44,14 @@ class MvvFileFileref extends ModuleManagementModel
* *
* @return string Name of the file. * @return string Name of the file.
*/ */
public function getFilename() public function getFilename(): string
{ {
if ($this->file_ref) { if ($this->file_ref) {
$filetype = $this->file_ref->getFileType(); $filetype = $this->file_ref->getFileType();
return $filetype->getFilename(); return $filetype->getFilename();
} }
throw new Exception("Could not load file ref for file");
} }
/** /**
...@@ -92,5 +94,7 @@ class MvvFileFileref extends ModuleManagementModel ...@@ -92,5 +94,7 @@ class MvvFileFileref extends ModuleManagementModel
} }
} }
} }
return false;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment