-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e6c662
commit 3800716
Showing
9 changed files
with
172 additions
and
75 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace SilverStripe\LinkField\Form\Traits; | ||
|
||
use SilverStripe\CMS\Controllers\ContentController; | ||
use SilverStripe\CMS\Controllers\CMSPageEditController; | ||
use SilverStripe\CMS\Model\SiteTree; | ||
use LogicException; | ||
|
||
trait OwnerFieldsTrait | ||
{ | ||
private function getOwnerFields() | ||
{ | ||
$form = $this->getForm(); | ||
$controller = $form->getController(); | ||
$owner = null; | ||
if (is_a($controller, ContentController::class)) { | ||
// TODO: confirm if this codepath is used for anything | ||
// TODO confirm if the below is correct | ||
$owner = $controller->data(); | ||
} elseif (is_a($controller, CMSPageEditController::class)) { | ||
// TODO: this code path is not used for elemental ... it's | ||
$pageID = (int) $controller->getRequest()->param('ID'); | ||
$owner = SiteTree::get()->byID($pageID); | ||
} | ||
if (!$owner) { | ||
throw new LogicException('Could not determine owner'); | ||
} | ||
return [ | ||
'ID' => $owner->ID, | ||
'ClassName' => $owner::class, | ||
'Relation' => $this->getName(), // TODO confirm | ||
]; | ||
} | ||
} |
Oops, something went wrong.