added avatars, show user teams in list, new team dashboard widgets (#1150)

This commit is contained in:
Kevin Papst
2019-10-03 13:44:16 +02:00
committed by GitHub
parent 718ad4b398
commit e8c25d8ac5
120 changed files with 2585 additions and 642 deletions

View File

@@ -0,0 +1,59 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Twig;
use App\Entity\User;
use App\Utils\AvatarService;
use Symfony\Component\Asset\Packages;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class AvatarExtension extends AbstractExtension
{
/**
* @var AvatarService
*/
private $avatar;
/**
* @var Packages
*/
private $packages;
public function __construct(AvatarService $avatar, Packages $packages)
{
$this->avatar = $avatar;
$this->packages = $packages;
}
/**
* {@inheritdoc}
*/
public function getFunctions()
{
return [
new TwigFunction('avatar', [$this, 'getAvatarUrl']),
];
}
public function getAvatarUrl(?User $profile, string $default): string
{
if (null === $profile) {
return $this->packages->getUrl($default);
}
$url = $this->avatar->getAvatar($profile);
if (null === $url) {
return $this->packages->getUrl($default);
}
return $this->packages->getUrl($url);
}
}