Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jellygnite committed Apr 13, 2021
1 parent 5c874e5 commit 83ab1a5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Model/BaseElementObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,18 @@ public function getPage()
// because $page can be a SiteTree or Controller
return $page instanceof SiteTree ? $page : null;
}


// method that can be overridden by indivudal element objects
public function getOwnerElement()
{
// You can't find the owner element of an object that hasn't been saved yet
if (!$this->isInDB()) {
return null;
}

return null;
}

public function getLinkURL()
{
if($link = $this->ElementLink){
Expand Down
10 changes: 10 additions & 0 deletions src/Model/GalleryObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@ public function getCMSFields()
return $fields;
}

public function getOwnerElement()
{
// You can't find the owner element of an object that hasn't been saved yet
if (!$this->isInDB()) {
return null;
}

return $this->ElementGallery()->First();
}

/**
* @return mixed
*/
Expand Down

0 comments on commit 83ab1a5

Please sign in to comment.