Fix missing link to admin.

This commit is contained in:
James Cole
2018-07-31 19:28:56 +02:00
parent 56518ea028
commit 1af45aff73
2 changed files with 23 additions and 2 deletions

View File

@@ -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
*/