-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AdminBar: Add native connection to Bar by Bridge service which is com…
…piled to DIC
- Loading branch information
1 parent
d33c168
commit c13576b
Showing
7 changed files
with
83 additions
and
40 deletions.
There are no files selected for viewing
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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Baraja\Cms\MiddleWare\Bridge; | ||
|
||
|
||
use Baraja\AdminBar\AdminBar; | ||
use Baraja\Cms\LinkGenerator; | ||
use Baraja\Cms\MenuAuthorizatorAccessor; | ||
use Nette\Security\User; | ||
|
||
final class AdminBarBridge | ||
{ | ||
public function __construct( | ||
private LinkGenerator $linkGenerator, | ||
private User $user, | ||
private MenuAuthorizatorAccessor $menuAuthorizator, | ||
) { | ||
} | ||
|
||
|
||
public function setup(): void | ||
{ | ||
$menu = AdminBar::getBar()->getMenu(); | ||
|
||
// Show link only in case of user can edit profile | ||
if ($this->menuAuthorizator->get()->isAllowedComponent('user', 'user-overview') === true) { | ||
$menu->addLink( | ||
'My Profile', | ||
$this->linkGenerator->link('User:detail', [ | ||
'id' => $this->user->getId(), | ||
]), | ||
'user', | ||
); | ||
} | ||
|
||
$menu->addLink('Settings', $this->linkGenerator->link('Settings:default'), 'ui'); | ||
$menu->addLink('Sign out', $this->linkGenerator->link('Cms:signOut'), 'ui'); | ||
} | ||
} |
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