mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 04:03:26 +00:00
Fix missing link to admin.
This commit is contained in:
@@ -24,6 +24,7 @@ namespace FireflyIII\Support\Twig;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Support\Twig\Extension\Account as AccountExtension;
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
use Route;
|
||||
@@ -45,7 +46,7 @@ class General extends Twig_Extension
|
||||
$this->balance(),
|
||||
$this->formatFilesize(),
|
||||
$this->mimeIcon(),
|
||||
$this->markdown(),
|
||||
$this->markdown()
|
||||
];
|
||||
}
|
||||
|
||||
@@ -64,6 +65,7 @@ class General extends Twig_Extension
|
||||
$this->activeRoutePartialWhat(),
|
||||
$this->formatDate(),
|
||||
new Twig_SimpleFunction('accountGetMetaField', [AccountExtension::class, 'getMetaField']),
|
||||
$this->hasRole(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -235,6 +237,25 @@ class General extends Twig_Extension
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Will return true if the user is of role X.
|
||||
*
|
||||
* @return Twig_SimpleFunction
|
||||
*/
|
||||
protected function hasRole(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'hasRole',
|
||||
function (string $role): bool {
|
||||
$repository = app(UserRepositoryInterface::class);
|
||||
if ($repository->hasRole(auth()->user(), $role)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Twig_SimpleFilter
|
||||
*/
|
||||
|
Reference in New Issue
Block a user