Skip to content

Commit

Permalink
#220 Adds function CollectionRole->addRootCollection() (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
extracts committed Feb 11, 2022
1 parent 95183db commit bc9df6d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions library/Opus/Model2/CollectionRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
*
* TODO add database property hide_empty_collections
* TODO add more functions from Opus\CollectionRole
* TODO implement isNewRecord()?
*/
class CollectionRole extends AbstractModel
{
Expand Down Expand Up @@ -446,6 +447,28 @@ public static function fetchByName($name = null)
return self::getRepository()->fetchByName($name);
}

/**
* Adds the given Collection node (or a new Collection node if none is given) as the root collection of
* this CollectionRole instance.
*
* @param Collection|null $root (Optional) The Collection node that shall be added as the root collection
* of this instance.
* @return Collection The root collection of this instance.
*/
public function addRootCollection($root = null)
{
// TODO DOCTRINE: ensure that this function has the same effect as Opus\CollectionRole->addRootCollection()

if ($root === null) {
$root = new Collection();
$root->setRole($this);
}

$this->setRootCollection($root);

return $root;
}

/**
* Returns the relevant properties of the class.
*
Expand Down

0 comments on commit bc9df6d

Please sign in to comment.