Skip to content

Commit

Permalink
Merge pull request #17 from zanderwar/patch-2
Browse files Browse the repository at this point in the history
Added "plugins" config option
  • Loading branch information
stevie-mayhew authored Jan 29, 2018
2 parents a47b99f + f5f51f5 commit 114e639
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/SingleObjectAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class SingleObjectAdmin extends LeftAndMain implements PermissionProvider
private static $allowed_actions = [
'EditForm'
];

/**
* @config
* @var array Allows developers to create adaptations to this plugin by giving a class name top-level uri access
*/
private static $plugins = [];

public function canView($member = null)
{
Expand Down Expand Up @@ -304,8 +310,13 @@ private function publish($data, $form)
*/
public function Link($action = null)
{
$allowedPlugins = $this->config()->get('plugins');
$allowedPlugins[] = SingleObjectAdmin::class;

$this->extend('updateAllowedPlugins', $allowedPlugins);

// LeftAndMain methods have a top-level uri access
if (static::class === SingleObjectAdmin::class) {
if (in_array(static::class, $allowedPlugins)) {
$segment = '';
} else {
// Get url_segment
Expand All @@ -319,5 +330,4 @@ public function Link($action = null)
$this->extend('updateLink', $link);
return $link;
}

}

0 comments on commit 114e639

Please sign in to comment.