Browse Source

Correctly get parent (#17)

* Correctly get parent

* Use the getFedoraRoot function to return NULL

* Incorrect function name
pull/756/head
Jared Whiklo 8 years ago committed by dannylamb
parent
commit
f6dcf5a149
  1. 17
      islandora/src/Entity/FedoraResource.php

17
islandora/src/Entity/FedoraResource.php

@ -235,21 +235,30 @@ class FedoraResource extends ContentEntityBase implements FedoraResourceInterfac
* {@inheritdoc} * {@inheritdoc}
*/ */
public function hasParent() { public function hasParent() {
return ($this->get('fedora_has_parent') !== NULL); return ($this->get('fedora_has_parent')->first() !== NULL);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getParent() { public function getParent() {
return $this->get('fedora_has_parent')->getEntity(); return $this->get('fedora_has_parent')
->first()
->get('entity')
->getTarget()
->getValue();
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getParentId() { public function getParentId() {
return $this->get('fedora_has_parent')->getEntity()->id(); return $this->get('fedora_has_parent')
->first()
->get('entity')
->getTarget()
->getValue()
->id();
} }
/** /**
@ -270,7 +279,7 @@ class FedoraResource extends ContentEntityBase implements FedoraResourceInterfac
*/ */
public static function getFedoraRoot() { public static function getFedoraRoot() {
// Just stub code, we need to figure out what "root is" in this context. // Just stub code, we need to figure out what "root is" in this context.
return array('root'); return NULL;
} }
/** /**

Loading…
Cancel
Save